diff --git a/.gitignore b/.gitignore index 702d58f4..2ebfdd7d 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,6 @@ composer.local.json .php-cs-fixer.cache composer.local.old pest.log +private-signing-key.pem +build.zip +build.zip.sig diff --git a/build-dev.sh b/build-dev.sh deleted file mode 100755 index fb55c2ac..00000000 --- a/build-dev.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -echo "# Deleting vendor folder..." -rm -r -f vendor -rm composer.lock - -echo "# Executing Composer..." -composer update --no-plugins - -echo "# Executing Scoper..." -vendor/bin/php-scoper add-prefix --force - -echo "# Migrating Build..." -rm -r -f vendor -mv build/vendor vendor -rm -r -f build diff --git a/build.sh b/build.sh index dac43cdd..c8a74453 100755 --- a/build.sh +++ b/build.sh @@ -1,5 +1,61 @@ #!/bin/bash -./build-dev.sh +# This script is used to build and package the plugin for distribution. +# It will clean up the environment, execute Composer, prefix dependencies, finalize the build, archive the build, and sign the archive. +function trim() { + local str="$*" + str="${str#"${str%%[![:space:]]*}"}" + str="${str%"${str##*[![:space:]]}"}" + echo "${str}" +} + +function semver { + local SEMVER_REGEX='^([0-9]+\.){2}(\*|[0-9]+)(-.*)?$' + local version=$(trim $1) + + if [[ "$version" =~ $SEMVER_REGEX ]]; then + if [ "$#" -eq 2 ]; then + local major=${BASH_REMATCH[0]} + local minor=${BASH_REMATCH[1]} + local patch=${BASH_REMATCH[2]} + local suffix=${BASH_REMATCH[3]} + eval "$2=(\"$major\" \"$minor\" \"$patch\" \"$suffix\")" + fi + else + echo "Error: version '$version' does not match the semver 'X.Y.Z' format." + exit 1 + fi +} + +printf 'What version are you building? ' +read version +echo "Version: $version" +semver "$version" version +filename="Auth0_WordPress_${version}.zip" + +echo "# Cleaning up environment..." +rm -f build.zip +rm -f build.zip.sig +rm -rf build +rm -rf vendor +rm composer.lock + +echo "# Executing Composer..." +composer update --no-plugins + +echo "# Prefixing Dependencies..." +vendor/bin/php-scoper add-prefix --force + +echo "# Finalizing Build..." +cd build composer update --no-dev --optimize-autoloader --no-plugins +rm composer.json +rm composer.lock +cd .. + +echo "# Archiving Build..." +zip -vr ${filename} build/ -x "*.DS_Store" + +echo "# Signing Build..." +openssl dgst -sign private-signing-key.pem -sha256 -out ${filename}.sig -binary ${filename} diff --git a/composer.json b/composer.json index 70aa1ada..845c476b 100644 --- a/composer.json +++ b/composer.json @@ -95,7 +95,7 @@ } }, "scripts": { - "package": "./build.sh", + "build": "./build.sh", "pest": "@php vendor/bin/pest --order-by random --fail-on-risky --parallel --no-progress", "pest:coverage": "@php vendor/bin/pest --order-by random --fail-on-risky --coverage --parallel --no-progress", "pest:debug": "@php vendor/bin/pest --log-events-verbose-text pest.log --display-errors --fail-on-risky --no-progress", diff --git a/scoper.inc.php b/scoper.inc.php index 071bf5ea..e3b16c9d 100644 --- a/scoper.inc.php +++ b/scoper.inc.php @@ -11,7 +11,7 @@ Finder::create() ->files() ->ignoreVCS(true) - ->notName('/LICENSE|.*\\.md|.*\\.dist|Makefile|composer\\.(json|lock)/') + ->notName('/.*\\.dist|Makefile|scoper.inc.php|rector.php|opslevel.yml|build.sh|public-signing-key.pub|composer.json|composer.lock/') ->exclude([ 'doc', 'test', @@ -28,7 +28,8 @@ ], 'exclude-namespaces' => [ - '/^Auth0\\\\WordPress\\\/', + '/^Auth0\\\\WordPress\\\\/', + '/^Auth0\\\\WordPress/', '/^Psr\\\/', ], diff --git a/src/Actions/Updates.php b/src/Actions/Updates.php index 8a46bb8f..b2f54c78 100644 --- a/src/Actions/Updates.php +++ b/src/Actions/Updates.php @@ -16,7 +16,7 @@ final class Updates extends Base public function doUpdateCheck($plugins) { - trap($plugins); + // trap($plugins); if (! is_object($plugins)) { return $plugins; @@ -26,12 +26,12 @@ public function doUpdateCheck($plugins) $plugins->response = []; } - $plugins->response['auth0/wpAuth0.php'] = (object) [ - 'slug' => 'auth0', - 'new_version' => '5.9', - 'url' => 'https://github.com/auth0/wordpress', - 'package' => 'https://github.com/auth0/wirdoress/archive/0.2.zip', - ]; + // $plugins->response['auth0/wpAuth0.php'] = (object) [ + // 'slug' => 'auth0', + // 'new_version' => '5.9', + // 'url' => 'https://github.com/auth0/wordpress', + // 'package' => 'https://github.com/auth0/wirdoress/archive/0.2.zip', + // ]; return $plugins; } diff --git a/updates.json b/updates.json new file mode 100644 index 00000000..b96b5d03 --- /dev/null +++ b/updates.json @@ -0,0 +1,5 @@ +{ + "5.3.0": { + "download": "Auth0_WordPress_5.3.0.zip" + } +} diff --git a/wpAuth0.php b/wpAuth0.php index 084a2179..4868e1e6 100644 --- a/wpAuth0.php +++ b/wpAuth0.php @@ -31,7 +31,9 @@ } // Load dependencies -if (file_exists(plugin_dir_path(__FILE__) . '/vendor/autoload.php')) { +if (file_exists(plugin_dir_path(__FILE__) . '/vendor/scoper-autoload.php')) { + require_once plugin_dir_path(__FILE__) . '/vendor/autoload.php'; +} elseif (file_exists(plugin_dir_path(__FILE__) . '/vendor/autoload.php')) { require_once plugin_dir_path(__FILE__) . '/vendor/autoload.php'; }