-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ba7dfd3
commit 507e3b0
Showing
1 changed file
with
60 additions
and
32 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 |
---|---|---|
@@ -1,48 +1,76 @@ | ||
#!/bin/sh | ||
|
||
#Script for create the plugin artifact | ||
echo "Tag: $TAG" | ||
|
||
if [ "$TAG" = "" ] | ||
then | ||
TAG='1.0.0' | ||
fi | ||
|
||
SRC_DIR="plugin" | ||
MAIN_FILE="webpay-rest.php" | ||
README_FILE="readme.txt" | ||
COMPOSER_FILE="composer.json" | ||
COMPOSER_LOCK_FILE="composer.lock" | ||
|
||
package_plugin() { | ||
echo "Packaging plugin." | ||
check_tag | ||
|
||
cd $SRC_DIR | ||
|
||
composer install --no-dev > /dev/null 2>&1 | ||
|
||
npm install --no-audit --no-fund --no-optional > /dev/null 2>&1 | ||
npm run build > /dev/null 2>&1 | ||
|
||
if [ $? -ne 0 ]; then | ||
echo "Command npm run build finished with error" 1>&2 | ||
exit 1 | ||
fi | ||
|
||
cd $SRC_DIR | ||
composer update | ||
composer install --no-dev | ||
npm install --no-audit --no-fund --no-optional | ||
npm run build | ||
if [ $? -eq 0 ]; then | ||
rm -rf node_modules/ | ||
else | ||
echo "Command npm run build finished with error" 1>&2 | ||
rm -rf node_modules/ | ||
exit 1 | ||
fi | ||
cd .. | ||
|
||
sed -i.bkp "s/Version: VERSION_REPLACE_HERE/Version: ${TAG#"v"}/g" "$SRC_DIR/$MAIN_FILE" | ||
sed -i.bkp "s/VERSION_REPLACE_HERE/${TAG#"v"}/g" "$SRC_DIR/$README_FILE" | ||
set_plugin_tag | ||
|
||
create_zip | ||
|
||
cd .. | ||
|
||
restore_files | ||
|
||
echo "\\nPlugin created, the detail is:" | ||
echo "- Version: $TAG" | ||
echo "- File name: $PLUGIN_FILE" | ||
} | ||
|
||
check_tag() { | ||
if [ "$TAG" = "" ] | ||
then | ||
echo "No Tag found. Using default Tag 1.0.0" | ||
TAG='1.0.0' | ||
fi | ||
|
||
echo "Tag: $TAG" | ||
} | ||
|
||
set_plugin_tag() { | ||
echo "Setting tag ${TAG#"v"} in readme and main file." | ||
|
||
sed -i.bkp "s/Version: VERSION_REPLACE_HERE/Version: ${TAG#"v"}/g" $MAIN_FILE | ||
sed -i.bkp "s/VERSION_REPLACE_HERE/${TAG#"v"}/g" $README_FILE | ||
} | ||
|
||
create_zip() { | ||
echo "Creating zip file." | ||
|
||
EXCLUSIONS="webpack.config.js *.lock *.json *.bkp" | ||
PLUGIN_FILE="transbank-webpay-plus-rest.zip" | ||
|
||
PLUGIN_FILE="transbank-webpay-plus-rest.zip" | ||
zip -FSr ../$PLUGIN_FILE . -x $EXCLUSIONS > /dev/null | ||
} | ||
|
||
cd $SRC_DIR | ||
zip -FSr ../$PLUGIN_FILE . -x composer.json composer.lock webpack.config.js package.json package-lock.json "*.bkp" | ||
restore_files() { | ||
echo "Restoring readme and main file." | ||
|
||
cd .. | ||
cp "$SRC_DIR/$MAIN_FILE.bkp" "$SRC_DIR/$MAIN_FILE" | ||
rm "$SRC_DIR/$MAIN_FILE.bkp" | ||
cp "$SRC_DIR/$README_FILE.bkp" "$SRC_DIR/$README_FILE" | ||
rm "$SRC_DIR/$README_FILE.bkp" | ||
} | ||
|
||
cp "$SRC_DIR/$MAIN_FILE.bkp" "$SRC_DIR/$MAIN_FILE" | ||
rm "$SRC_DIR/$MAIN_FILE.bkp" | ||
cp "$SRC_DIR/$README_FILE.bkp" "$SRC_DIR/$README_FILE" | ||
rm "$SRC_DIR/$README_FILE.bkp" | ||
package_plugin | ||
|
||
echo "Plugin version: $TAG" | ||
echo "Plugin file: $PLUGIN_FILE" |