build-zip.sh
40 lines
| 1 | #!/bin/sh |
| 2 | |
| 3 | PLUGIN_SLUG="everest-forms" |
| 4 | PROJECT_PATH=$(pwd) |
| 5 | BUILD_PATH="${PROJECT_PATH}/build" |
| 6 | DEST_PATH="$BUILD_PATH/$PLUGIN_SLUG" |
| 7 | |
| 8 | echo "Generating build directory..." |
| 9 | rm -rf "$BUILD_PATH" |
| 10 | mkdir -p "$DEST_PATH" |
| 11 | |
| 12 | echo "Installing PHP and JS dependencies..." |
| 13 | npm install --legacy-peer-deps || exit "$?" |
| 14 | # --ignore-platform-reqs: composer.lock has dev-only packages (phpunit and |
| 15 | # friends) locked to versions requiring old PHP, while the actual production |
| 16 | # dependencies need a newer PHP -- no single installed PHP version can ever |
| 17 | # satisfy both at once. Composer validates the whole lock file's platform |
| 18 | # requirements up front regardless of which packages are actually going to |
| 19 | # be installed, so this is needed on both calls below, not just the --no-dev |
| 20 | # one, even though the first call still installs the dev packages that |
| 21 | # trigger the conflict. |
| 22 | composer install --ignore-platform-reqs || exit "$?" |
| 23 | echo "Running JS Build..." |
| 24 | npm run build:core || exit "$?" |
| 25 | echo "Cleaning up PHP dependencies..." |
| 26 | composer install --no-dev --ignore-platform-reqs || exit "$?" |
| 27 | |
| 28 | echo "Syncing files..." |
| 29 | rsync -rc --exclude-from="$PROJECT_PATH/.distignore" "$PROJECT_PATH/" "$DEST_PATH/" --delete --delete-excluded |
| 30 | |
| 31 | echo "Generating zip file..." |
| 32 | cd "$BUILD_PATH" || exit |
| 33 | zip -q -r "${PLUGIN_SLUG}.zip" "$PLUGIN_SLUG/" |
| 34 | |
| 35 | cd "$PROJECT_PATH" || exit |
| 36 | mv "$BUILD_PATH/${PLUGIN_SLUG}.zip" "$PROJECT_PATH" |
| 37 | echo "${PLUGIN_SLUG}.zip file generated!" |
| 38 | |
| 39 | echo "Build done!" |
| 40 |