-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy pathpost-merge
More file actions
executable file
·63 lines (56 loc) · 2.88 KB
/
post-merge
File metadata and controls
executable file
·63 lines (56 loc) · 2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env sh
. "$(dirname "$0")/_/husky.sh"
# Load local env variables if present.
if [ -f "$(pwd)/local.env" ]; then
. "$(pwd)/local.env"
fi
# using `--no-install` just in case it's the first time a person is checking out the repo and doesn't have yarnhook installed
npx --no-install yarnhook
# make sure composer packages are installed and the autoload files are regenerated
# --ignore-platform-req=php allows dev-only packages (like qit-cli) that need PHP 7.4+
composer install --ignore-platform-req=php
# Auto-update WCPay Dev Tools plugin (for non-Docker setups or custom paths)
# With Docker shared volumes, the plugin is managed via docker-setup.sh
DEV_TOOLS_PLUGIN_PATH=${LOCAL_WCPAY_DEV_TOOLS_PLUGIN_REPO_PATH:-""}
if [ -z "$DEV_TOOLS_PLUGIN_PATH" ]; then
# No custom path set - check if using Docker volumes
if docker volume inspect wcpay-plugins > /dev/null 2>&1; then
# Using Docker volumes - dev tools are managed by docker-setup.sh
# To manually update: delete the plugin from the volume and re-run npm run up:recreate
:
else
# Not using Docker volumes, check the legacy default path
DEV_TOOLS_PLUGIN_PATH="docker/wordpress/wp-content/plugins/woocommerce-payments-dev-tools"
fi
fi
if [ -n "$DEV_TOOLS_PLUGIN_PATH" ] && [ -d "$DEV_TOOLS_PLUGIN_PATH" ]; then
if [ "$(cd "$DEV_TOOLS_PLUGIN_PATH" && git rev-parse --show-toplevel 2>/dev/null)" = "$(cd "$DEV_TOOLS_PLUGIN_PATH" && pwd)" ]; then
echo
echo "\033[32mDetermining if there is an update for the WCPay Dev Tools plugin...\033[0m"
DEV_TOOLS_BRANCH=$(cd "$DEV_TOOLS_PLUGIN_PATH" && git branch --show-current)
if [ "$DEV_TOOLS_BRANCH" = "trunk" ]; then
echo " \033[32mThe current branch is trunk. Check if we are safe to pull from origin/trunk...\033[0m"
if [ "$(cd "$DEV_TOOLS_PLUGIN_PATH" && git status --porcelain)" ]; then
echo "\033[33m There are uncommitted local changes on the WCPay Dev Tools repo. Skipping any attempt to update it.\033[0m"
else
echo " \033[32mPulling the latest changes from origin/trunk, if any...\033[0m"
DEV_TOOLS_HEAD_BEFORE=$(cd "$DEV_TOOLS_PLUGIN_PATH" && git rev-parse HEAD)
(cd "$DEV_TOOLS_PLUGIN_PATH" && git pull)
DEV_TOOLS_HEAD_AFTER=$(cd "$DEV_TOOLS_PLUGIN_PATH" && git rev-parse HEAD)
# Install dependencies and build only when new changes were pulled
if [ "$DEV_TOOLS_HEAD_BEFORE" != "$DEV_TOOLS_HEAD_AFTER" ]; then
if [ -f "$DEV_TOOLS_PLUGIN_PATH/composer.json" ]; then
echo " \033[32mInstalling WCPay Dev Tools Composer dependencies...\033[0m"
(cd "$DEV_TOOLS_PLUGIN_PATH" && composer install)
fi
if [ -f "$DEV_TOOLS_PLUGIN_PATH/package.json" ]; then
echo " \033[32mBuilding WCPay Dev Tools...\033[0m"
(cd "$DEV_TOOLS_PLUGIN_PATH" && npm install && npm run build)
fi
fi
fi
else
echo "\033[33m The WCPay Dev Tools local clone is not on the trunk branch. Skipping any attempt to update it.\033[0m"
fi
fi
fi