From b5a65f050a11e084397a5e231cd123b008bc3415 Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Fri, 13 Oct 2017 08:43:29 +1100 Subject: [PATCH] feat: add pact-stub-service to standalone package --- packaging/README.md.template | 7 +++++++ packaging/generate_readme_contents.rb | 1 + packaging/pact-stub-service.bat | 17 +++++++++++++++++ packaging/pact-stub-service.rb | 2 ++ packaging/pact-stub-service.sh | 25 +++++++++++++++++++++++++ tasks/package.rake | 3 +++ 6 files changed, 55 insertions(+) create mode 100644 packaging/pact-stub-service.bat create mode 100644 packaging/pact-stub-service.rb create mode 100755 packaging/pact-stub-service.sh diff --git a/packaging/README.md.template b/packaging/README.md.template index bb88bbe..886e70f 100644 --- a/packaging/README.md.template +++ b/packaging/README.md.template @@ -20,6 +20,13 @@ This version (<%= ENV.fetch('VERSION') %>) of the Pact standalone executables pa <%= pact_mock_service_usage %> ``` +### pact-stub-service + +``` +<%= pact_stub_service_usage %> +``` + + ### pact-provider-verifier ``` diff --git a/packaging/generate_readme_contents.rb b/packaging/generate_readme_contents.rb index bdc8e64..f7417a5 100644 --- a/packaging/generate_readme_contents.rb +++ b/packaging/generate_readme_contents.rb @@ -6,6 +6,7 @@ require 'pact_broker/client/version' pact_mock_service_usage = `bundle exec pact-mock-service help` + `bundle exec pact-mock-service help service` +pact_stub_service_usage = `bundle exec pact-stub-service help` pact_provider_verifier_usage = `bundle exec pact-provider-verifier help` pact_publish_usage = `bundle exec pact-publish help` puts ERB.new(ARGF.read).result(binding) diff --git a/packaging/pact-stub-service.bat b/packaging/pact-stub-service.bat new file mode 100644 index 0000000..b37eaff --- /dev/null +++ b/packaging/pact-stub-service.bat @@ -0,0 +1,17 @@ +@echo off + +SET RUNNING_PATH=%~dp0 +CALL :RESOLVE "%RUNNING_PATH%\.." ROOT_PATH + +:: Tell Bundler where the Gemfile and gems are. +set "BUNDLE_GEMFILE=%ROOT_PATH%\lib\vendor\Gemfile" +set BUNDLE_IGNORE_CONFIG= + +:: Run the actual app using the bundled Ruby interpreter, with Bundler activated. +@"%ROOT_PATH%\lib\ruby\bin\ruby.bat" -rbundler/setup -I%ROOT_PATH%\lib\app\lib "%ROOT_PATH%\lib\app\pact-stub-service.rb" %* + +GOTO :EOF + +:RESOLVE +SET %2=%~f1 +GOTO :EOF diff --git a/packaging/pact-stub-service.rb b/packaging/pact-stub-service.rb new file mode 100644 index 0000000..8a07bd0 --- /dev/null +++ b/packaging/pact-stub-service.rb @@ -0,0 +1,2 @@ +require 'pact/stub_service/cli' +Pact::StubService::CLI.start diff --git a/packaging/pact-stub-service.sh b/packaging/pact-stub-service.sh new file mode 100755 index 0000000..45433cf --- /dev/null +++ b/packaging/pact-stub-service.sh @@ -0,0 +1,25 @@ +#!/bin/sh +set -e + +SOURCE="$0" +while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink + TARGET="$(readlink "$SOURCE")" + if [[ $TARGET == /* ]]; then + SOURCE="$TARGET" + else + DIR="$( dirname "$SOURCE" )" + SOURCE="$DIR/$TARGET" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located + fi +done +RDIR="$( dirname "$SOURCE" )" +DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + +# Figure out where this script is located. +LIBDIR="`cd \"$DIR\" && cd ../lib && pwd`" + +# Tell Bundler where the Gemfile and gems are. +export BUNDLE_GEMFILE="$LIBDIR/vendor/Gemfile" +unset BUNDLE_IGNORE_CONFIG + +# Run the actual app using the bundled Ruby interpreter, with Bundler activated. +exec "$LIBDIR/ruby/bin/ruby" -rreadline -rbundler/setup -I$LIBDIR/app/lib "$LIBDIR/app/pact-stub-service.rb" $@ diff --git a/tasks/package.rake b/tasks/package.rake index 95ddb14..38d8023 100644 --- a/tasks/package.rake +++ b/tasks/package.rake @@ -75,6 +75,7 @@ def create_package(version, target, os_type = :unix) sh "mkdir -p #{package_dir}/bin" sh "cp build/README.md #{package_dir}" sh "cp packaging/pact-mock-service.rb #{package_dir}/lib/app/pact-mock-service.rb" + sh "cp packaging/pact-stub-service.rb #{package_dir}/lib/app/pact-stub-service.rb" sh "cp packaging/pact-provider-verifier.rb #{package_dir}/lib/app/pact-provider-verifier.rb" sh "cp packaging/pact-publish.rb #{package_dir}/lib/app/pact-publish.rb" # sh "cp -pR lib #{package_dir}/lib/app" @@ -83,10 +84,12 @@ def create_package(version, target, os_type = :unix) if os_type == :unix sh "cp packaging/pact-mock-service.sh #{package_dir}/bin/pact-mock-service" + sh "cp packaging/pact-stub-service.sh #{package_dir}/bin/pact-stub-service" sh "cp packaging/pact-provider-verifier.sh #{package_dir}/bin/pact-provider-verifier" sh "cp packaging/pact-publish.sh #{package_dir}/bin/pact-publish" else sh "cp packaging/pact-mock-service.bat #{package_dir}/bin/pact-mock-service.bat" + sh "cp packaging/pact-stub-service.bat #{package_dir}/bin/pact-stub-service.bat" sh "cp packaging/pact-provider-verifier.bat #{package_dir}/bin/pact-provider-verifier.bat" sh "cp packaging/pact-publish.bat #{package_dir}/bin/pact-publish.bat" end