Skip to content

Commit 9ed1d30

Browse files
committed
feat: add pact docs to standalone package
1 parent 446665d commit 9ed1d30

File tree

6 files changed

+74
-17
lines changed

6 files changed

+74
-17
lines changed

packaging/README.md.template

+9-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ This version (<%= ENV.fetch('VERSION') %>) of the Pact standalone executables pa
4949
#### can-i-deploy
5050

5151
```
52-
<%= pact_broker_can_i_deploy %>
52+
<%= pact_broker_can_i_deploy_usage %>
5353
```
5454

55+
<a name="pact"></a>
56+
### pact
57+
58+
<a name="pact-docs"></a>
59+
#### docs
60+
```
61+
<%= pact_docs_usage %>
62+
```

packaging/generate_readme_contents.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
pact_stub_service_usage = `bundle exec pact-stub-service help`
1010
pact_provider_verifier_usage = `bundle exec pact-provider-verifier help`
1111
pact_publish_usage = `bundle exec pact-broker help publish`
12-
pact_broker_can_i_deploy = `bundle exec pact-broker help can-i-deploy`
12+
pact_broker_can_i_deploy_usage = `bundle exec pact-broker help can-i-deploy`
13+
pact_docs_usage = `bundle exec pact help docs`
1314
puts ERB.new(ARGF.read).result(binding)

packaging/pact.bat

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
@echo off
2+
3+
SET RUNNING_PATH=%~dp0
4+
CALL :RESOLVE "%RUNNING_PATH%\.." ROOT_PATH
5+
6+
:: Tell Bundler where the Gemfile and gems are.
7+
set "BUNDLE_GEMFILE=%ROOT_PATH%\lib\vendor\Gemfile"
8+
set BUNDLE_IGNORE_CONFIG=
9+
10+
:: Run the actual app using the bundled Ruby interpreter, with Bundler activated.
11+
@"%ROOT_PATH%\lib\ruby\bin\ruby.bat" -rbundler/setup -I%ROOT_PATH%\lib\app\lib "%ROOT_PATH%\lib\app\pact.rb" %*
12+
13+
GOTO :EOF
14+
15+
:RESOLVE
16+
SET %2=%~f1
17+
GOTO :EOF

packaging/pact.rb

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
require 'pact/cli'
2+
3+
class Thor
4+
module Base
5+
module ClassMethods
6+
7+
def basename
8+
# chomps the trailing .rb so it doesn't show in the help text
9+
File.basename($PROGRAM_NAME).split(" ").first.chomp(".rb")
10+
end
11+
end
12+
end
13+
end
14+
15+
Pact::CLI.start

packaging/pact.sh

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/sh
2+
set -e
3+
4+
SOURCE="$0"
5+
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
6+
TARGET="$(readlink "$SOURCE")"
7+
if [[ $TARGET == /* ]]; then
8+
SOURCE="$TARGET"
9+
else
10+
DIR="$( dirname "$SOURCE" )"
11+
SOURCE="$DIR/$TARGET" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
12+
fi
13+
done
14+
RDIR="$( dirname "$SOURCE" )"
15+
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
16+
17+
# Figure out where this script is located.
18+
LIBDIR="`cd \"$DIR\" && cd ../lib && pwd`"
19+
20+
# Tell Bundler where the Gemfile and gems are.
21+
export BUNDLE_GEMFILE="$LIBDIR/vendor/Gemfile"
22+
unset BUNDLE_IGNORE_CONFIG
23+
24+
# Run the actual app using the bundled Ruby interpreter, with Bundler activated.
25+
exec "$LIBDIR/ruby/bin/ruby" -rreadline -rbundler/setup -I "$LIBDIR/app/lib" "$LIBDIR/app/pact.rb" "$@"

tasks/package.rake

+6-15
Original file line numberDiff line numberDiff line change
@@ -83,27 +83,18 @@ def create_package(version, target, os_type = :unix)
8383
sh "mkdir -p #{package_dir}/lib/app"
8484
sh "mkdir -p #{package_dir}/bin"
8585
sh "cp build/README.md #{package_dir}"
86-
sh "cp packaging/pact-mock-service.rb #{package_dir}/lib/app/pact-mock-service.rb"
87-
sh "cp packaging/pact-stub-service.rb #{package_dir}/lib/app/pact-stub-service.rb"
88-
sh "cp packaging/pact-provider-verifier.rb #{package_dir}/lib/app/pact-provider-verifier.rb"
89-
sh "cp packaging/pact-publish.rb #{package_dir}/lib/app/pact-publish.rb"
90-
sh "cp packaging/pact-broker.rb #{package_dir}/lib/app/pact-broker.rb"
86+
sh "cp packaging/pact*.rb #{package_dir}/lib/app"
87+
9188
# sh "cp -pR lib #{package_dir}/lib/app"
9289
sh "mkdir #{package_dir}/lib/ruby"
9390
sh "tar -xzf build/traveling-ruby-#{version}-#{target}.tar.gz -C #{package_dir}/lib/ruby"
9491

9592
if os_type == :unix
96-
sh "cp packaging/pact-mock-service.sh #{package_dir}/bin/pact-mock-service"
97-
sh "cp packaging/pact-stub-service.sh #{package_dir}/bin/pact-stub-service"
98-
sh "cp packaging/pact-provider-verifier.sh #{package_dir}/bin/pact-provider-verifier"
99-
sh "cp packaging/pact-publish.sh #{package_dir}/bin/pact-publish"
100-
sh "cp packaging/pact-broker.sh #{package_dir}/bin/pact-broker"
93+
Dir.chdir('packaging'){ Dir['pact*.sh'] }.each do | name |
94+
sh "cp packaging/#{name} #{package_dir}/bin/#{name.chomp('.sh')}"
95+
end
10196
else
102-
sh "cp packaging/pact-mock-service.bat #{package_dir}/bin/pact-mock-service.bat"
103-
sh "cp packaging/pact-stub-service.bat #{package_dir}/bin/pact-stub-service.bat"
104-
sh "cp packaging/pact-provider-verifier.bat #{package_dir}/bin/pact-provider-verifier.bat"
105-
sh "cp packaging/pact-publish.bat #{package_dir}/bin/pact-publish.bat"
106-
sh "cp packaging/pact-broker.bat #{package_dir}/bin/pact-broker.bat"
97+
sh "cp packaging/pact*.bat #{package_dir}/bin"
10798
end
10899

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

0 commit comments

Comments
 (0)