-
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.
Merge pull request #267 from TransbankDevelopers/chore/remove-zip-guz…
…zle7-creation
- Loading branch information
Showing
2 changed files
with
66 additions
and
62 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
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,63 +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" | ||
cp "$SRC_DIR/$COMPOSER_LOCK_FILE" "$SRC_DIR/$COMPOSER_LOCK_FILE.bkp" | ||
|
||
PLUGIN_FILE="transbank-webpay-plus-rest.zip" | ||
PLUGIN_FILE_GUZZLE="transbank-webpay-plus-rest-guzzle7.zip" | ||
|
||
cd $SRC_DIR | ||
zip -FSr ../$PLUGIN_FILE . -x composer.json composer.lock webpack.config.js package.json package-lock.json "*.bkp" | ||
|
||
# Create Guzzle 7 version | ||
sed -i.bkp "s/\"php\": \"7.0\"/\"php\": \"7.2.5\"/g" "$COMPOSER_FILE" | ||
composer require guzzlehttp/guzzle:^7.0 | ||
zip -FSr ../$PLUGIN_FILE_GUZZLE . -x composer.json composer.lock webpack.config.js package.json package-lock.json "*.bkp" | ||
|
||
cp "$COMPOSER_LOCK_FILE.bkp" "$COMPOSER_LOCK_FILE" | ||
rm "$COMPOSER_LOCK_FILE.bkp" | ||
cp "$COMPOSER_FILE.bkp" "$COMPOSER_FILE" | ||
rm "$COMPOSER_FILE.bkp" | ||
composer update | ||
composer install | ||
|
||
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" | ||
|
||
echo "Plugin version: $TAG" | ||
echo "Plugin file: $PLUGIN_FILE" | ||
echo "Plugin file Guzzle 7: $PLUGIN_FILE_GUZZLE" | ||
|
||
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" | ||
|
||
zip -FSr ../$PLUGIN_FILE . -x $EXCLUSIONS > /dev/null | ||
} | ||
|
||
restore_files() { | ||
echo "Restoring readme and main file." | ||
|
||
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 | ||
|