From 32d2b79e7831e11abda9e63476bd983d2cd1dd08 Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Thu, 7 May 2020 13:11:20 -0300 Subject: [PATCH] Introduced script to generate a zip package --- bin/build-zip.sh | 32 ++++++++++++++++++++++++++++++++ package.json | 1 + 2 files changed, 33 insertions(+) create mode 100755 bin/build-zip.sh diff --git a/bin/build-zip.sh b/bin/build-zip.sh new file mode 100755 index 0000000000000..a80eaa9c928ed --- /dev/null +++ b/bin/build-zip.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +PLUGIN_SLUG="woocommerce" +PROJECT_PATH=$(pwd) +BUILD_PATH="${PROJECT_PATH}/build" +DEST_PATH="$BUILD_PATH/$PLUGIN_SLUG" + +echo "Generating build directory..." +rm -rf "$BUILD_PATH" +mkdir -p "$DEST_PATH" + +echo "Installing PHP and JS dependencies..." +npm install +composer install || exit "$?" +echo "Running JS Build..." +npm run build || exit "$?" +echo "Cleaning up PHP dependencies..." +composer install --no-dev || exit "$?" + +echo "Syncing files..." +rsync -rc --exclude-from="$PROJECT_PATH/.distignore" "$PROJECT_PATH/" "$DEST_PATH/" --delete --delete-excluded + +echo "Restoring PHP dependencies..." +composer install || exit "$?" +npm run build || exit "$?" + +echo "Generating zip file..." +cd "$BUILD_PATH" || exit +zip -q -r "${PLUGIN_SLUG}.zip" "$PLUGIN_SLUG/" +echo "$BUILD_PATH/${PLUGIN_SLUG}.zip file generated!" + +echo "Build done!" diff --git a/package.json b/package.json index d39aab8703b8d..c0fd2c79db853 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "scripts": { "build": "grunt && npm run makepot", "build-watch": "grunt watch", + "build:zip": "./bin/build-zip.sh", "lint:js": "eslint assets/js --ext=js", "test:e2e": "./tests/bin/e2e-test-integration.js", "test:e2e-dev": "./tests/bin/e2e-test-integration.js --dev",