-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor build scripts #91
base: main
Are you sure you want to change the base?
Conversation
Thanks for the PR 😍 How to test these changes in your application
Diff between recipe versionsIn order to help with the review stage, I'm in charge of computing the diff between the various versions of patched recipes. shopware/administration6.4 vs 6.6diff --git a/shopware/administration/6.4/bin/build-administration.sh b/shopware/administration/6.6/bin/build-administration.sh
index f590aa5..9c37c3a 100755
--- a/shopware/administration/6.4/bin/build-administration.sh
+++ b/shopware/administration/6.6/bin/build-administration.sh
@@ -1,84 +1,49 @@
#!/usr/bin/env bash
-CWD="$(cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)"
+set -euo pipefail
+# Set project root directory
+CWD="$(cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)"
export PROJECT_ROOT="${PROJECT_ROOT:-"$(dirname "$CWD")"}"
export ENV_FILE=${ENV_FILE:-"${PROJECT_ROOT}/.env"}
-# shellcheck source=functions.sh
+# Source functions
source "${PROJECT_ROOT}/bin/functions.sh"
-curenv=$(declare -p -x)
-
+# Load environment variables from .env file
load_dotenv "$ENV_FILE"
+# Load current environment variables
+curenv=$(declare -p -x)
+
# Restore environment variables set globally
set -o allexport
eval "$curenv"
set +o allexport
-set -euo pipefail
-
+# Puppeteer and admin configurations
export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
export DISABLE_ADMIN_COMPILATION_TYPECHECK=true
-export PROJECT_ROOT="${PROJECT_ROOT:-"$(dirname "$CWD")"}"
+export ADMIN_ROOT="${ADMIN_ROOT:-"${PROJECT_ROOT}/vendor/shopware/administration"}"
-if [[ -e "${PROJECT_ROOT}/vendor/shopware/platform" ]]; then
- ADMIN_ROOT="${ADMIN_ROOT:-"${PROJECT_ROOT}/vendor/shopware/platform/src/Administration"}"
-else
- ADMIN_ROOT="${ADMIN_ROOT:-"${PROJECT_ROOT}/vendor/shopware/administration"}"
-fi
+# Ensure BIN_TOOL is set and executable
+get_bin_tool
-BIN_TOOL="${CWD}/console"
-
-if [[ ${CI:-""} ]]; then
- BIN_TOOL="${CWD}/ci"
-
- if [[ ! -x "$BIN_TOOL" ]]; then
- chmod +x "$BIN_TOOL"
- fi
-fi
-
-# build admin
+# Dump bundles and features if not skipped
[[ ${SHOPWARE_SKIP_BUNDLE_DUMP:-""} ]] || "${BIN_TOOL}" bundle:dump
-"${BIN_TOOL}" feature:dump || true
-
-if [[ $(command -v jq) ]]; then
- OLDPWD=$(pwd)
- cd "$PROJECT_ROOT" || exit
-
- jq -c '.[]' "var/plugins.json" | while read -r config; do
- srcPath=$(echo "$config" | jq -r '(.basePath + .administration.path)')
+[[ ${SHOPWARE_SKIP_FEATURE_DUMP:-""} ]] || "${BIN_TOOL}" feature:dump
- # the package.json files are always one upper
- path=$(dirname "$srcPath")
- name=$(echo "$config" | jq -r '.technicalName' )
+# Install administration npm dependencies for extensions
+install_extensions_npm_dependencies "administration"
- skippingEnvVarName="SKIP_$(echo "$name" | sed -e 's/\([a-z]\)/\U\1/g' -e 's/-/_/g')"
-
- if [[ ${!skippingEnvVarName:-""} ]]; then
- continue
- fi
-
- if [[ -f "$path/package.json" && ! -d "$path/node_modules" && $name != "administration" ]]; then
- echo "=> Installing npm dependencies for ${name}"
-
- npm install --prefix "$path" --no-audit --prefer-offline
- fi
- done
- cd "$OLDPWD" || exit
-else
- echo "Cannot check extensions for required npm installations as jq is not installed"
-fi
-
-(cd "${ADMIN_ROOT}"/Resources/app/administration && npm install --no-audit --prefer-offline)
+# Install npm dependencies for administration in production mode
+npm --prefix "${ADMIN_ROOT}/Resources/app/administration" install --production
# Dump entity schema
-if [[ -z "${SHOPWARE_SKIP_ENTITY_SCHEMA_DUMP:-""}" ]] && [[ -f "${ADMIN_ROOT}"/Resources/app/administration/scripts/entitySchemaConverter/entity-schema-converter.ts ]]; then
- mkdir -p "${ADMIN_ROOT}"/Resources/app/administration/test/_mocks_
- "${BIN_TOOL}" -e prod framework:schema -s 'entity-schema' "${ADMIN_ROOT}"/Resources/app/administration/test/_mocks_/entity-schema.json
- (cd "${ADMIN_ROOT}"/Resources/app/administration && npm run convert-entity-schema)
-fi
+dump_entity_schema
+
+# Build administration
+npm --prefix "${ADMIN_ROOT}/Resources/app/administration" run build
-(cd "${ADMIN_ROOT}"/Resources/app/administration && npm run build)
-[[ ${SHOPWARE_SKIP_ASSET_COPY:-""} ]] ||"${BIN_TOOL}" assets:install
+# Install assets if not skipped
+[[ ${SHOPWARE_SKIP_ASSET_COPY:-""} ]] || "${BIN_TOOL}" assets:install
diff --git a/shopware/administration/6.4/bin/watch-administration.sh b/shopware/administration/6.6/bin/watch-administration.sh
index 060866e..8189b36 100755
--- a/shopware/administration/6.4/bin/watch-administration.sh
+++ b/shopware/administration/6.6/bin/watch-administration.sh
@@ -1,69 +1,48 @@
#!/usr/bin/env bash
-CWD="$(cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)"
+set -euo pipefail
+# Set project root directory
+CWD="$(cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)"
export PROJECT_ROOT="${PROJECT_ROOT:-"$(dirname "$CWD")"}"
export ENV_FILE=${ENV_FILE:-"${PROJECT_ROOT}/.env"}
-# shellcheck source=functions.sh
+# Source functions
source "${PROJECT_ROOT}/bin/functions.sh"
-curenv=$(declare -p -x)
-
+# Load environment variables from .env file
load_dotenv "$ENV_FILE"
+# Load current environment variables
+curenv=$(declare -p -x)
+
# Restore environment variables set globally
set -o allexport
eval "$curenv"
set +o allexport
-export HOST=${HOST:-"localhost"}
+# Set default values for environment variables
+export APP_URL
export ESLINT_DISABLE
+export HOST=${HOST:-"localhost"}
export PORT
-export APP_URL
+export ADMIN_ROOT="${ADMIN_ROOT:-"${PROJECT_ROOT}/vendor/shopware/administration"}"
-BIN_TOOL="${CWD}/console"
+# Ensure BIN_TOOL is set and executable
+get_bin_tool
+# Dump bundles and features if not skipped
[[ ${SHOPWARE_SKIP_BUNDLE_DUMP:-""} ]] || "${BIN_TOOL}" bundle:dump
-"${BIN_TOOL}" feature:dump || true
-
-if [[ $(command -v jq) ]]; then
- OLDPWD=$(pwd)
- cd "$PROJECT_ROOT" || exit
-
- jq -c '.[]' "var/plugins.json" | while read -r config; do
- srcPath=$(echo "$config" | jq -r '(.basePath + .administration.path)')
-
- # the package.json files are always one upper
- path=$(dirname "$srcPath")
- name=$(echo "$config" | jq -r '.technicalName' )
-
- skippingEnvVarName="SKIP_$(echo "$name" | sed -e 's/\([a-z]\)/\U\1/g' -e 's/-/_/g')"
-
- if [[ ${!skippingEnvVarName:-""} ]]; then
- continue
- fi
-
- if [[ -f "$path/package.json" && ! -d "$path/node_modules" && $name != "administration" ]]; then
- echo "=> Installing npm dependencies for ${name}"
+[[ ${SHOPWARE_SKIP_FEATURE_DUMP:-""} ]] || "${BIN_TOOL}" feature:dump
- npm install --prefix "$path"
- fi
- done
- cd "$OLDPWD" || exit
-else
- echo "Cannot check extensions for required npm installations as jq is not installed"
-fi
+# Install webpack-dev-server if not present
+[[ ! -d "${ADMIN_ROOT}"/Resources/app/administration/node_modules/webpack-dev-server ]] && npm --prefix "${ADMIN_ROOT}"/Resources/app/administration install || true
-if [ ! -d vendor/shopware/administration/Resources/app/administration/node_modules ]; then
- npm install --prefix vendor/shopware/administration/Resources/app/administration/
-fi
+# Install administration npm dependencies for extensions
+install_extensions_npm_dependencies "administration"
# Dump entity schema
-if [[ -z "${SHOPWARE_SKIP_ENTITY_SCHEMA_DUMP:-""}" ]] && [[ -f "${ADMIN_ROOT}"/Resources/app/administration/scripts/entitySchemaConverter/entity-schema-converter.ts ]]; then
- mkdir -p "${ADMIN_ROOT}"/Resources/app/administration/test/_mocks_
- "${BIN_TOOL}" -e prod framework:schema -s 'entity-schema' "${ADMIN_ROOT}"/Resources/app/administration/test/_mocks_/entity-schema.json
- (cd "${ADMIN_ROOT}"/Resources/app/administration && npm run convert-entity-schema)
-fi
+dump_entity_schema
-npm run --prefix vendor/shopware/administration/Resources/app/administration/ dev
+# Build administration in development mode
+npm --prefix "${ADMIN_ROOT}/Resources/app/administration" run dev shopware/core6.4 vs 6.6diff --git a/shopware/core/6.4/bin/ci b/shopware/core/6.6/bin/ci
index e9f453b..661c0fa 100755
--- a/shopware/core/6.4/bin/ci
+++ b/shopware/core/6.6/bin/ci
@@ -3,7 +3,6 @@
use Shopware\Core\Framework\Adapter\Kernel\KernelFactory;
use Shopware\Core\Framework\Plugin\KernelPluginLoader\ComposerPluginLoader;
-use Shopware\Core\HttpKernel;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;
@@ -39,18 +38,12 @@ return static function (array &$context) {
$_SERVER['DATABASE_URL'] = 'mysql://_placeholder.test';
}
- if (method_exists(KernelFactory::class, "create")) {
- $kernel = KernelFactory::create(
- environment: $env,
- debug: $debug,
- classLoader: $classLoader,
- pluginLoader: new ComposerPluginLoader($classLoader, null)
- );
- } else {
- $kernel = new HttpKernel($env, $debug, $classLoader);
- $kernel->setPluginLoader(new ComposerPluginLoader($classLoader, null));
- $kernel = $kernel->getKernel();
- }
+ $kernel = KernelFactory::create(
+ environment: $env,
+ debug: $debug,
+ classLoader: $classLoader,
+ pluginLoader: new ComposerPluginLoader($classLoader, null),
+ );
$application = new Application($kernel);
$kernel->boot();
diff --git a/shopware/core/6.4/bin/console b/shopware/core/6.6/bin/console
index 6ec51be..5d89fb3 100755
--- a/shopware/core/6.4/bin/console
+++ b/shopware/core/6.6/bin/console
@@ -4,7 +4,6 @@
use Shopware\Core\Framework\Adapter\Kernel\KernelFactory;
use Shopware\Core\Framework\Plugin\KernelPluginLoader\DbalKernelPluginLoader;
use Shopware\Core\Framework\Plugin\KernelPluginLoader\StaticKernelPluginLoader;
-use Shopware\Core\HttpKernel;
use Shopware\Core\Kernel;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;
@@ -40,25 +39,16 @@ return static function (array &$context) {
$context['INSTALL'] = true;
}
- if (trim($context['DATABASE_URL'] ?? '') === '') {
- // fake DATABASE_URL
- $_SERVER['DATABASE_URL'] = 'mysql://_placeholder.test';
- } else if (!isset($context['INSTALL'])) {
- $pluginLoader = new DbalKernelPluginLoader($classLoader, null, \Shopware\Core\Kernel::getConnection());
+ if (trim($context['DATABASE_URL'] ?? '') !== '' && !isset($context['INSTALL'])) {
+ $pluginLoader = new DbalKernelPluginLoader($classLoader, null, Kernel::getConnection());
}
- if (method_exists(KernelFactory::class, "create")) {
- $kernel = KernelFactory::create(
- environment: $env,
- debug: $debug,
- classLoader: $classLoader,
- pluginLoader: $pluginLoader
- );
- } else {
- $kernel = new HttpKernel($env, $debug, $classLoader);
- $kernel->setPluginLoader($pluginLoader);
- $kernel = $kernel->getKernel();
- }
+ $kernel = KernelFactory::create(
+ environment: $env,
+ debug: $debug,
+ classLoader: $classLoader,
+ pluginLoader: $pluginLoader
+ );
$application = new Application($kernel);
$kernel->boot();
diff --git a/shopware/core/6.4/bin/functions.sh b/shopware/core/6.6/bin/functions.sh
index 4e7cff2..965e8b3 100644
--- a/shopware/core/6.4/bin/functions.sh
+++ b/shopware/core/6.6/bin/functions.sh
@@ -8,7 +8,7 @@ load_dotenv() {
fi
CURRENT_ENV=${APP_ENV:-"dev"}
- env_file="$1"
+ local env_file="$1"
# If we have an actual .env file load it
if [[ -e "$env_file" ]]; then
@@ -37,3 +37,81 @@ load_dotenv() {
source "$env_file.$CURRENT_ENV.local"
fi
}
+
+get_bin_tool() {
+ local bin_tool_path="${CWD}/console"
+
+ if [[ -n ${CI:-} ]]; then
+ bin_tool_path="${CWD}/ci"
+
+ if [[ ! -x "$bin_tool_path" ]]; then
+ chmod +x "$bin_tool_path"
+ fi
+ fi
+
+ BIN_TOOL="$bin_tool_path"
+}
+
+dump_entity_schema() {
+ # Check if entity schema dump should be skipped or the file exists
+ if [[ -z "${SHOPWARE_SKIP_ENTITY_SCHEMA_DUMP:-}" ]] && \
+ [[ -f "${ADMIN_ROOT}/Resources/app/administration/scripts/entitySchemaConverter/entity-schema-converter.ts" ]]; then
+
+ local mocks_dir="${ADMIN_ROOT}/Resources/app/administration/test/_mocks_"
+
+ # Ensure mocks directory exists
+ mkdir -p "$mocks_dir"
+
+ # Generate entity schema JSON
+ "${BIN_TOOL}" -e prod framework:schema -s 'entity-schema' "${mocks_dir}/entity-schema.json"
+
+ # Convert entity schema JSON
+ npm --prefix "${ADMIN_ROOT}/Resources/app/administration" run convert-entity-schema
+ fi
+}
+
+install_extensions_npm_dependencies() {
+ local component_name="$1"
+ local npm_args=${2:-""}
+
+ if [[ $(command -v jq) ]]; then
+ OLDPWD=$(pwd)
+ cd "$PROJECT_ROOT" || exit
+
+ jq -c '.[]' "var/plugins.json" | while read -r config; do
+ srcPath=$(echo "$config" | jq -r "(.basePath + .${component_name}.path)")
+
+ # the package.json files are always one upper
+ path=$(dirname "$srcPath")
+ name=$(echo "$config" | jq -r '.technicalName' )
+
+ skippingEnvVarName="SKIP_$(echo "$name" | sed -e 's/\([a-z]\)/\U\1/g' -e 's/-/_/g')"
+
+ if [[ ${!skippingEnvVarName:-""} ]]; then
+ continue
+ fi
+
+ if [[ -f "$path/package.json" && ! -d "$path/node_modules" && $name != "$component_name" ]]; then
+ echo "=> Installing npm dependencies for ${name}"
+
+ npm --prefix "$path" install $npm_args
+ fi
+ done
+ cd "$OLDPWD" || exit
+ else
+ echo "Cannot check extensions for required npm installations as jq is not installed"
+ fi
+}
+
+install_and_build_storefront() {
+ local storefront_app_dir="${STOREFRONT_ROOT}/Resources/app/storefront"
+
+ # Install npm dependencies for storefront
+ npm --prefix "$storefront_app_dir" install --prefer-offline --production
+
+ # Copy to vendor
+ node "$storefront_app_dir/copy-to-vendor.js"
+
+ # Run production build
+ npm --prefix "$storefront_app_dir" run production
+}
diff --git a/shopware/core/6.4/post-install.txt b/shopware/core/6.6/post-install.txt
index 36869a6..18d1b8f 100644
--- a/shopware/core/6.4/post-install.txt
+++ b/shopware/core/6.6/post-install.txt
@@ -19,8 +19,3 @@
5. Optional: Open the Mail catcher with symfony open:local:webmail
* Read the documentation at https://developer.shopware.com/
-
- * Warning if updating from older versions of the production template:
-
- There might be old `require-dev` dependencies in your `composer.json` file. Please remove them before updating shopware/core to versions >= v6.4.
- You can do it using this command: composer config --unset require-dev
diff --git a/shopware/core/6.4/public/index.php b/shopware/core/6.6/public/index.php
index eb330c6..61c8694 100644
--- a/shopware/core/6.4/public/index.php
+++ b/shopware/core/6.6/public/index.php
@@ -2,13 +2,9 @@
use Shopware\Core\DevOps\Environment\EnvironmentHelper;
use Shopware\Core\Framework\Plugin\KernelPluginLoader\ComposerPluginLoader;
-use Shopware\Core\HttpKernel;
use Shopware\Core\Installer\InstallerKernel;
-use Symfony\Component\HttpFoundation\Request;
use Shopware\Core\Framework\Adapter\Kernel\KernelFactory;
use Symfony\Component\HttpFoundation\Response;
-use Symfony\Component\HttpKernel\HttpKernelInterface;
-use Symfony\Component\HttpKernel\TerminableInterface;
$_SERVER['SCRIPT_FILENAME'] = __FILE__;
@@ -34,62 +30,20 @@ return function (array $context) {
$appEnv = $context['APP_ENV'] ?? 'dev';
$debug = (bool) ($context['APP_DEBUG'] ?? ($appEnv !== 'prod'));
- $trustedProxies = $context['TRUSTED_PROXIES'] ?? false;
- if ($trustedProxies) {
- Request::setTrustedProxies(
- explode(',', $trustedProxies),
- Request::HEADER_X_FORWARDED_FOR | Request::HEADER_X_FORWARDED_PORT | Request::HEADER_X_FORWARDED_PROTO
- );
- }
-
- $trustedHosts = $context['TRUSTED_HOSTS'] ?? false;
- if ($trustedHosts) {
- Request::setTrustedHosts(explode(',', $trustedHosts));
- }
-
if (!EnvironmentHelper::getVariable('SHOPWARE_SKIP_WEBINSTALLER', false) && !file_exists(dirname(__DIR__) . '/install.lock')) {
return new InstallerKernel($appEnv, $debug);
}
- if (method_exists(KernelFactory::class, "create")) {
- $pluginLoader = null;
- if (EnvironmentHelper::getVariable('COMPOSER_PLUGIN_LOADER', false)) {
- $pluginLoader = new ComposerPluginLoader($classLoader, null);
- }
-
- return KernelFactory::create(
- environment: $appEnv,
- debug: $debug,
- classLoader: $classLoader,
- pluginLoader: $pluginLoader
- );
- }
-
- $shopwareHttpKernel = new HttpKernel($appEnv, $debug, $classLoader);
+ $pluginLoader = null;
if (EnvironmentHelper::getVariable('COMPOSER_PLUGIN_LOADER', false)) {
- $shopwareHttpKernel->setPluginLoader(
- new ComposerPluginLoader($classLoader, null)
- );
+ $pluginLoader = new ComposerPluginLoader($classLoader, null);
}
- return new class($shopwareHttpKernel) implements HttpKernelInterface, TerminableInterface {
- private HttpKernel $httpKernel;
-
- public function __construct(HttpKernel $httpKernel)
- {
- $this->httpKernel = $httpKernel;
- }
-
- public function handle(Request $request, int $type = self::MAIN_REQUEST, bool $catch = true): Response
- {
- return $this->httpKernel->handle($request, $type, $catch)->getResponse();
- }
-
- public function terminate(Request $request, Response $response): void
- {
- $this->httpKernel->terminate($request, $response);
- }
- };
+ return KernelFactory::create(
+ environment: $appEnv,
+ debug: $debug,
+ classLoader: $classLoader,
+ pluginLoader: $pluginLoader
+ );
};
-
diff --git a/shopware/core/6.6/root/.npmrc b/shopware/core/6.6/root/.npmrc
new file mode 100644
index 0000000..9ab81d7
--- /dev/null
+++ b/shopware/core/6.6/root/.npmrc
@@ -0,0 +1,6 @@
+fund=false
+audit=false
+update-notifier=false
+prefer-offline=true
+progress=false
+loglevel=silent shopware/storefront6.4 vs 6.6diff --git a/shopware/storefront/6.4/bin/build-storefront.sh b/shopware/storefront/6.6/bin/build-storefront.sh
index 410d5a7..58fd996 100755
--- a/shopware/storefront/6.4/bin/build-storefront.sh
+++ b/shopware/storefront/6.6/bin/build-storefront.sh
@@ -1,62 +1,38 @@
#!/usr/bin/env bash
-CWD="$(cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)"
-
set -euo pipefail
-export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
+# Set project root directory
+CWD="$(cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)"
export PROJECT_ROOT="${PROJECT_ROOT:-"$(dirname "$CWD")"}"
-if [[ -e "${PROJECT_ROOT}/vendor/shopware/platform" ]]; then
- STOREFRONT_ROOT="${STOREFRONT_ROOT:-"${PROJECT_ROOT}/vendor/shopware/platform/src/Storefront"}"
-else
- STOREFRONT_ROOT="${STOREFRONT_ROOT:-"${PROJECT_ROOT}/vendor/shopware/storefront"}"
-fi
+# Source functions
+source "${PROJECT_ROOT}/bin/functions.sh"
-BIN_TOOL="${CWD}/console"
+# Puppeteer and storefront configurations
+export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
+export STOREFRONT_ROOT="${STOREFRONT_ROOT:-"${PROJECT_ROOT}/vendor/shopware/storefront"}"
-if [[ ${CI:-""} ]]; then
- BIN_TOOL="${CWD}/ci"
+# Ensure BIN_TOOL is set and executable
+get_bin_tool
- if [[ ! -x "$BIN_TOOL" ]]; then
- chmod +x "$BIN_TOOL"
- fi
-fi
-
-# build storefront
+# Dump bundles and features if not skipped
[[ ${SHOPWARE_SKIP_BUNDLE_DUMP:-""} ]] || "${BIN_TOOL}" bundle:dump
[[ ${SHOPWARE_SKIP_FEATURE_DUMP:-""} ]] || "${BIN_TOOL}" feature:dump
-if [[ $(command -v jq) ]]; then
- OLDPWD=$(pwd)
- cd "$PROJECT_ROOT" || exit
-
- jq -c '.[]' "var/plugins.json" | while read -r config; do
- srcPath=$(echo "$config" | jq -r '(.basePath + .storefront.path)')
-
- # the package.json files are always one upper
- path=$(dirname "$srcPath")
- name=$(echo "$config" | jq -r '.technicalName' )
+# Install storefront npm dependencies for extensions
+install_extensions_npm_dependencies "storefront"
- skippingEnvVarName="SKIP_$(echo "$name" | sed -e 's/\([a-z]\)/\U\1/g' -e 's/-/_/g')"
+# Install and build storefront
+install_and_build_storefront
- if [[ ${!skippingEnvVarName:-""} ]]; then
- continue
- fi
+# Install assets if not skipped
+[[ ${SHOPWARE_SKIP_ASSET_COPY:-""} ]] ||"${BIN_TOOL}" assets:install
- if [[ -f "$path/package.json" && ! -d "$path/node_modules" && $name != "storefront" ]]; then
- echo "=> Installing npm dependencies for ${name}"
+# Compile theme if not skipped
+[[ ${SHOPWARE_SKIP_THEME_COMPILE:-""} ]] || "${BIN_TOOL}" theme:compile --active-only
- npm install --prefix "$path" --no-audit --prefer-offline
- fi
- done
- cd "$OLDPWD" || exit
-else
- echo "Cannot check extensions for required npm installations as jq is not installed"
+# Clear cache if not instructed otherwise
+if ! [ "${1:-default}" = "--keep-cache" ]; then
+ "${BIN_TOOL}" cache:clear
fi
-
-npm --prefix "${STOREFRONT_ROOT}"/Resources/app/storefront install --no-audit --prefer-offline
-node "${STOREFRONT_ROOT}"/Resources/app/storefront/copy-to-vendor.js
-npm --prefix "${STOREFRONT_ROOT}"/Resources/app/storefront run production
-[[ ${SHOPWARE_SKIP_ASSET_COPY:-""} ]] ||"${BIN_TOOL}" assets:install
-[[ ${SHOPWARE_SKIP_THEME_COMPILE:-""} ]] || "${BIN_TOOL}" theme:compile
diff --git a/shopware/storefront/6.4/bin/watch-storefront.sh b/shopware/storefront/6.6/bin/watch-storefront.sh
index f6c9015..fffb8b9 100755
--- a/shopware/storefront/6.4/bin/watch-storefront.sh
+++ b/shopware/storefront/6.6/bin/watch-storefront.sh
@@ -1,58 +1,48 @@
#!/usr/bin/env bash
-CWD="$(cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)"
+set -euo pipefail
+# Set project root directory
+CWD="$(cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)"
export PROJECT_ROOT="${PROJECT_ROOT:-"$(dirname "$CWD")"}"
export ENV_FILE=${ENV_FILE:-"${PROJECT_ROOT}/.env"}
-# shellcheck source=functions.sh
+# Source functions
source "${PROJECT_ROOT}/bin/functions.sh"
-curenv=$(declare -p -x)
-
+# Load environment variables from .env file
load_dotenv "$ENV_FILE"
+# Load current environment variables
+curenv=$(declare -p -x)
+
# Restore environment variables set globally
set -o allexport
eval "$curenv"
set +o allexport
+# Set default values for environment variables
export APP_URL
export ESLINT_DISABLE
export PROXY_URL
export STOREFRONT_ASSETS_PORT
export STOREFRONT_PROXY_PORT
+export STOREFRONT_ROOT="${STOREFRONT_ROOT:-"${PROJECT_ROOT}/vendor/shopware/storefront"}"
-DATABASE_URL="" "${CWD}"/console feature:dump
-"${CWD}"/console theme:compile
-"${CWD}"/console theme:dump
-
-if [[ $(command -v jq) ]]; then
- OLDPWD=$(pwd)
- cd "$PROJECT_ROOT" || exit
-
- jq -c '.[]' "var/plugins.json" | while read -r config; do
- srcPath=$(echo "$config" | jq -r '(.basePath + .storefront.path)')
-
- # the package.json files are always one upper
- path=$(dirname "$srcPath")
- name=$(echo "$config" | jq -r '.technicalName' )
-
- skippingEnvVarName="SKIP_$(echo "$name" | sed -e 's/\([a-z]\)/\U\1/g' -e 's/-/_/g')"
+# Ensure BIN_TOOL is set and executable
+get_bin_tool
- if [[ ${!skippingEnvVarName:-""} ]]; then
- continue
- fi
+# Dump features and compile theme if not skipped
+[[ ${SHOPWARE_SKIP_BUNDLE_DUMP:-""} ]] || "${BIN_TOOL}" bundle:dump
+[[ ${SHOPWARE_SKIP_FEATURE_DUMP:-""} ]] || "${BIN_TOOL}" feature:dump
+[[ ${SHOPWARE_SKIP_THEME_COMPILE:-""} ]] || "${BIN_TOOL}" theme:compile --active-only
+"${BIN_TOOL}" theme:dump
- if [[ -f "$path/package.json" && ! -d "$path/node_modules" && $name != "storefront" ]]; then
- echo "=> Installing npm dependencies for ${name}"
+# Install webpack-dev-server if not present
+[[ ! -d "${STOREFRONT_ROOT}"/Resources/app/storefront/node_modules/webpack-dev-server ]] && npm --prefix "${STOREFRONT_ROOT}"/Resources/app/storefront install || true
- npm install --prefix "$path"
- fi
- done
- cd "$OLDPWD" || exit
-else
- echo "Cannot check extensions for required npm installations as jq is not installed"
-fi
+# Install extensions npm dependencies
+install_extensions_npm_dependencies "storefront"
-npm --prefix vendor/shopware/storefront/Resources/app/storefront/ run-script hot-proxy
+# Run hot-proxy script
+npm --prefix "${STOREFRONT_ROOT}"/Resources/app/storefront run-script hot-proxy |
# Conflicts: # shopware/storefront/6.6/bin/watch-storefront.sh
Hey, I tested it, and everything seems to work, but the global environment variables are not working anymore.
|
The I've changed that in our local scripts to |
The existing build and watcher scripts lack consistency.
The refactored storefront and administration build scripts and watchers are more clear and consistent now, they are sharing the same flow and functionalities.
Npm configurations are extracted outside bash scripts into .npmrc project file.