Skip to content

Commit

Permalink
feat(binstubs): expose pact standalone binaries as alternative CLI
Browse files Browse the repository at this point in the history
feat(binstubs): expose pact standalone binaries as alternative CLI
  • Loading branch information
TimothyJones authored May 28, 2019
2 parents 7a11f44 + 5c164da commit 02f16cc
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 1 deletion.
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ An idiomatic Node interface for the [Pact](http://pact.io) mock service (Consume
- [Create Message Pacts](#create-message-pacts)
- [Example](#example)
- [Example CLI invocation:](#example-cli-invocation)
- [CLI Tools](#cli-tools)
- [Windows Issues](#windows-issues)
- [Enable Long Paths](#enable-long-paths)
- [Contributing](#contributing)
Expand Down Expand Up @@ -402,6 +403,33 @@ node ./bin/pact-cli.js message --pact-file-write-mode update --consumer foo --pr
}'
```

## CLI Tools

This package also comes with the [Pact Standalone Tools](https://github.com/pact-foundation/pact-ruby-standalone/releases) available as linked binaries in the [standard](https://docs.npmjs.com/files/folders#executables) NPM installation directory (e..g. `./node_modules/.bin`).

These are available in circumstances where `pact-node` has not yet implemented a feature or access via JavaScript APIs is not desirable. To run the binaries is as simple as the following:

*Example can-i-deploy check*:
```sh
./node_modules/.bin/pact-broker can-i-deploy --pacticipant "Banana Service" --broker-base-url https://test.pact.dius.com.au --latest --broker-username dXfltyFMgNOFZAxr8io9wJ37iUpY42M --broker-password O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1

Computer says no ¯\_(ツ)_/¯

CONSUMER | C.VERSION | PROVIDER | P.VERSION | SUCCESS?
---------------|-----------|----------------|-----------|---------
Banana Service | 1.0.0 | Fofana Service | 1.0.0 | false

The verification between the latest version of Banana Service (1.0.0) and version 1.0.0 of Fofana Service failed
```

The following are the binaries currently made available:

* `pact-mock-service`
* `pact-broker`
* `pact-stub-service`
* `pact-message`
* `pact-provider-verifier`

## Windows Issues

### Enable Long Paths
Expand Down
6 changes: 6 additions & 0 deletions bin/pact-broker.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env node

import standalone from "../src/pact-standalone";
const spawnSync = require("child_process").spawnSync;

spawnSync(standalone.brokerFullPath, process.argv.slice(2), {stdio: "inherit"});
6 changes: 6 additions & 0 deletions bin/pact-message.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env node

import standalone from "../src/pact-standalone";
const spawnSync = require("child_process").spawnSync;

spawnSync(standalone.messageFullPath, process.argv.slice(2), {stdio: "inherit"});
6 changes: 6 additions & 0 deletions bin/pact-mock-service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env node

import standalone from "../src/pact-standalone";
const spawnSync = require("child_process").spawnSync;

spawnSync(standalone.mockServiceFullPath, process.argv.slice(2), {stdio: "inherit"});
6 changes: 6 additions & 0 deletions bin/pact-provider-verifier.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env node

import standalone from "../src/pact-standalone";
const spawnSync = require("child_process").spawnSync;

spawnSync(standalone.verifierFullPath, process.argv.slice(2), {stdio: "inherit"});
6 changes: 6 additions & 0 deletions bin/pact-stub-service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env node

import standalone from "../src/pact-standalone";
const spawnSync = require("child_process").spawnSync;

spawnSync(standalone.stubFullPath, process.argv.slice(2), {stdio: "inherit"});
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
"homepage": "https://github.com/pact-foundation/pact-node#readme",
"types": "src/index.d.ts",
"bin": {
"pact": "bin/pact-cli.js"
"pact": "bin/pact-cli.js",
"pact-broker": "bin/pact-broker.js",
"pact-mock-service": "bin/pact-mock-service.js",
"pact-stub-service": "bin/pact-stub-service.js",
"pact-provider-verifier": "bin/pact-provider-verifier.js",
"pact-message": "bin/pact-message.js"
},
"os": [
"darwin",
Expand Down

0 comments on commit 02f16cc

Please sign in to comment.