Skip to content

Commit

Permalink
feat: add pact-stub-service to standalone package
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Oct 12, 2017
1 parent 03cf5a8 commit b5a65f0
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packaging/README.md.template
Original file line number Diff line number Diff line change
Expand Up @@ -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

```
Expand Down
1 change: 1 addition & 0 deletions packaging/generate_readme_contents.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
17 changes: 17 additions & 0 deletions packaging/pact-stub-service.bat
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions packaging/pact-stub-service.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require 'pact/stub_service/cli'
Pact::StubService::CLI.start
25 changes: 25 additions & 0 deletions packaging/pact-stub-service.sh
Original file line number Diff line number Diff line change
@@ -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" $@
3 changes: 3 additions & 0 deletions tasks/package.rake
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down

0 comments on commit b5a65f0

Please sign in to comment.