forked from shopware/shopware
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NEXT-26798 - Install npm dependencies for extensions on init:js
- Loading branch information
1 parent
89e9f80
commit 7cc1f0d
Showing
6 changed files
with
337 additions
and
193 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/usr/bin/env bash | ||
|
||
CWD="$(cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)" | ||
|
||
set -euo pipefail | ||
|
||
export PROJECT_ROOT="${PROJECT_ROOT:-"$(dirname "$CWD")"}" | ||
|
||
"$CWD"/console bundle:dump | ||
|
||
if ! [[ $(command -v jq) ]]; then | ||
echo "Cannot check extensions for required npm installations as jq is not installed" | ||
exit 1 | ||
fi | ||
|
||
OLDPWD=$(pwd) | ||
cd "$PROJECT_ROOT" || exit | ||
|
||
jq -c '.[]' "var/plugins.json" | while read -r config; do | ||
srcPath=$(echo "$config" | jq -r '.basePath') | ||
adminPath=$(echo "$config" | jq -r '(.basePath + .administration.path)') | ||
storefrontPath=$(echo "$config" | jq -r '(.basePath + .storefront.path)') | ||
bundlePaths=() | ||
|
||
if [[ -d "$adminPath" ]]; then | ||
bundlePaths+=("$adminPath") | ||
fi | ||
|
||
if [[ -d "$storefrontPath" ]]; then | ||
bundlePaths+=("$storefrontPath") | ||
fi | ||
|
||
if [[ ${#bundlePaths[@]} -eq 0 ]]; then | ||
continue | ||
fi | ||
|
||
# the package.json files are always one upper | ||
path=$(dirname "$srcPath") | ||
name=$(echo "$config" | jq -r '.technicalName') | ||
|
||
for bundlePath in "${bundlePaths[@]}"; do | ||
if [[ $path == "custom/plugins/"* && -f "$bundlePath/../package.json" && ! -d "$bundlePath/../node_modules" ]]; then | ||
bundleName="administration" | ||
|
||
if [[ "$bundlePath" == *"storefront"* ]]; then | ||
bundleName="storefront" | ||
fi | ||
|
||
echo "=> Installing ${bundleName} npm dependencies for ${name}" | ||
|
||
if [[ -f "$bundlePath/../package-lock.json" ]]; then | ||
npm --prefix "$bundlePath/../" clean-install --no-audit --prefer-offline | ||
else | ||
npm --prefix "$bundlePath/../" install --no-audit --prefer-offline | ||
fi | ||
fi | ||
done | ||
done | ||
|
||
cd "$OLDPWD" || exit |
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
Oops, something went wrong.