Skip to content

Commit

Permalink
feat(pact publish): add pact-publish cli
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Sep 30, 2017
1 parent f82f7ff commit 9f760a3
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 14 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.4
1.5.0
1 change: 1 addition & 0 deletions packaging/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ source 'http://rubygems.org'

gem "pact-mock_service"
gem "pact-provider-verifier"
gem "pact_broker-client"
8 changes: 8 additions & 0 deletions packaging/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ GEM
faraday_middleware (0.12.2)
faraday (>= 0.7.4, < 1.0)
find_a_port (1.0.1)
httparty (0.15.6)
multi_xml (>= 0.5.2)
json (2.1.0)
multi_xml (0.6.0)
multipart-post (2.0.0)
pact (1.15.0)
json (> 1.8.5)
Expand Down Expand Up @@ -48,6 +51,10 @@ GEM
rspec (>= 2.14)
term-ansicolor (~> 1.0)
thor
pact_broker-client (1.5.0)
httparty
json
term-ansicolor
rack (2.0.3)
rack-proxy (0.6.2)
rack
Expand Down Expand Up @@ -83,6 +90,7 @@ PLATFORMS
DEPENDENCIES
pact-mock_service
pact-provider-verifier
pact_broker-client

BUNDLED WITH
1.15.3
13 changes: 0 additions & 13 deletions packaging/README.md

This file was deleted.

2 changes: 2 additions & 0 deletions packaging/README.md.template
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This version (<%= ENV.fetch('VERSION') %>) of the Pact standalone executables pa
* pact-mock_service gem <%= Pact::MockService::VERSION %>
* pact-support gem <%= Pact::Support::VERSION %>
* pact-provider-verifier gem <%= Pact::ProviderVerifier::VERSION %>
* pact_broker-client gem <%= PactBroker::Client::VERSION %>

## Usage

Expand All @@ -19,4 +20,5 @@ This version (<%= ENV.fetch('VERSION') %>) of the Pact standalone executables pa
cd pact/bin
./pact-mock-service --help start # will display the options for the mock service
./pact-provider-verifier --help verify # will display the options for the verifier
./pact-publish --help # will display the options for publishing
```
1 change: 1 addition & 0 deletions packaging/generate_readme_contents.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
require 'pact/mock_service/version'
require 'pact/support/version'
require 'pact/provider_verifier/version'
require 'pact_broker/client/version'

puts ERB.new(ARGF.read).result(binding)
17 changes: 17 additions & 0 deletions packaging/pact-publish.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-publish.rb" %*

GOTO :EOF

:RESOLVE
SET %2=%~f1
GOTO :EOF
2 changes: 2 additions & 0 deletions packaging/pact-publish.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require 'pact_broker/client/cli/publish'
PactBroker::Client::CLI::Publish.start
26 changes: 26 additions & 0 deletions packaging/pact-publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
set -e

SOURCE="${BASH_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
unset RUBYGEMS_GEMDEPS # See https://github.com/pact-foundation/pact-mock-service-npm/issues/16

# Run the actual app using the bundled Ruby interpreter, with Bundler activated.
exec "$LIBDIR/ruby/bin/ruby" -rbundler/setup -rreadline -I$LIBDIR/app/lib "$LIBDIR/app/pact-publish.rb" $@
3 changes: 3 additions & 0 deletions tasks/package.rake
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,19 @@ def create_package(version, target, os_type = :unix)
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-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"
sh "mkdir #{package_dir}/lib/ruby"
sh "tar -xzf build/traveling-ruby-#{version}-#{target}.tar.gz -C #{package_dir}/lib/ruby"

if os_type == :unix
sh "cp packaging/pact-mock-service.sh #{package_dir}/bin/pact-mock-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-provider-verifier.bat #{package_dir}/bin/pact-provider-verifier.bat"
sh "cp packaging/pact-publish.bat #{package_dir}/bin/pact-publish.bat"
end

sh "cp -pR build/vendor #{package_dir}/lib/"
Expand Down

0 comments on commit 9f760a3

Please sign in to comment.