Skip to content

Commit d795d75

Browse files
authored
feat: add pact rust cli tools (#89)
* feat: add pact rust cli tools - pact_mock_server_cli - pact-plugin-cli - pact_verifier_cli - pact-stub-server * chore: update binstubs * chore(win): update to use exe path for rust executables * chore(docs): readme cleanup and final traveling ruby refs
1 parent 4cd44a8 commit d795d75

File tree

11 files changed

+194
-11
lines changed

11 files changed

+194
-11
lines changed

.github/workflows/update.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Update Pact Ruby Standalone
1+
name: Update Pact Standalone
22

33
on:
44
repository_dispatch:

README.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
## Pact CLI Tools
3939

40-
This package wraps the [Pact Standalone Tools](https://github.com/pact-foundation/pact-ruby-standalone/releases) so that they are available to node scripts in package.json, and linked binaries in the [standard](https://docs.npmjs.com/files/folders#executables) NPM installation directory (e..g. `./node_modules/.bin`).
40+
This package wraps the [Pact Standalone Tools](https://github.com/pact-foundation/pact-standalone/releases) so that they are available to node scripts in package.json, and linked binaries in the [standard](https://docs.npmjs.com/files/folders#executables) NPM installation directory (e..g. `./node_modules/.bin`).
4141

4242
For example:
4343

@@ -66,16 +66,20 @@ The verification between the latest version of Banana Service (1.0.0) and versio
6666

6767
The following are the binaries currently made available:
6868

69-
- `pact-mock-service`
7069
- `pact-broker`
71-
- `pact-stub-service`
72-
- `pact-message`
73-
- `pact-provider-verifier`
74-
- `pact`
70+
- `pact` (top level cli)
71+
- `pact-mock-server`
72+
- `pact-verifier`
73+
- `pact-stub-server`
74+
- `pact-plugin`
75+
- `pact-mock-service` (legacy)
76+
- `pact-stub-service` (legacy)
77+
- `pact-message` (legacy)
78+
- `pact-provider-verifier` (legacy)
7579

7680
## Pact-CLI API
7781

78-
A wrapper for the [Pact](http://pact.io) [CLI Tools](https://github.com/pact-foundation/pact-ruby-standalone).
82+
A wrapper for the [Pact](http://pact.io) [CLI Tools](https://github.com/pact-foundation/pact-standalone).
7983

8084
## Installation
8185

bin/pact-mock-server.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env node
2+
3+
import childProcess = require('child_process');
4+
import {
5+
standalone,
6+
standaloneUseShell,
7+
setStandaloneArgs,
8+
} from '../src/pact-standalone';
9+
10+
const args = process.argv.slice(2);
11+
const opts = standaloneUseShell ? { shell: true } : {};
12+
13+
const { error, status } = childProcess.spawnSync(
14+
standalone().mockServerFullPath,
15+
setStandaloneArgs(args, standaloneUseShell),
16+
{
17+
stdio: 'inherit',
18+
...opts,
19+
}
20+
);
21+
if (error) throw error;
22+
process.exit(status as number);

bin/pact-plugin.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env node
2+
3+
import childProcess = require('child_process');
4+
import {
5+
standalone,
6+
standaloneUseShell,
7+
setStandaloneArgs,
8+
} from '../src/pact-standalone';
9+
10+
const args = process.argv.slice(2);
11+
const opts = standaloneUseShell ? { shell: true } : {};
12+
13+
const { error, status } = childProcess.spawnSync(
14+
standalone().pluginFullPath,
15+
setStandaloneArgs(args, standaloneUseShell),
16+
{
17+
stdio: 'inherit',
18+
...opts,
19+
}
20+
);
21+
if (error) throw error;
22+
process.exit(status as number);

bin/pact-stub-server.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env node
2+
3+
import childProcess = require('child_process');
4+
import {
5+
standalone,
6+
standaloneUseShell,
7+
setStandaloneArgs,
8+
} from '../src/pact-standalone';
9+
10+
const args = process.argv.slice(2);
11+
const opts = standaloneUseShell ? { shell: true } : {};
12+
13+
const { error, status } = childProcess.spawnSync(
14+
standalone().stubServerFullPath,
15+
setStandaloneArgs(args, standaloneUseShell),
16+
{
17+
stdio: 'inherit',
18+
...opts,
19+
}
20+
);
21+
if (error) throw error;
22+
process.exit(status as number);

bin/pact-verifier.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env node
2+
3+
import childProcess = require('child_process');
4+
import {
5+
standalone,
6+
standaloneUseShell,
7+
setStandaloneArgs,
8+
} from '../src/pact-standalone';
9+
10+
const args = process.argv.slice(2);
11+
const opts = standaloneUseShell ? { shell: true } : {};
12+
13+
const { error, status } = childProcess.spawnSync(
14+
standalone().verifierRustFullPath,
15+
setStandaloneArgs(args, standaloneUseShell),
16+
{
17+
stdio: 'inherit',
18+
...opts,
19+
}
20+
);
21+
if (error) throw error;
22+
process.exit(status as number);

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
"pact-broker": "bin/pact-broker.js",
1111
"pact-mock-service": "bin/pact-mock-service.js",
1212
"pact-stub-service": "bin/pact-stub-service.js",
13+
"pact-mock-server": "bin/pact-mock-server.js",
14+
"pact-stub-server": "bin/pact-stub-server.js",
15+
"pact-plugin": "bin/pact-plugin.js",
16+
"pact-verifier": "bin/pact-verifier.js",
1317
"pact-provider-verifier": "bin/pact-provider-verifier.js",
1418
"pact-message": "bin/pact-message.js",
1519
"pactflow": "bin/pactflow.js"

script/lib/download-standalone.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ function download_standalone {
4040
fi
4141
}
4242

43-
log "Downloading Ruby standalone ${STANDALONE_VERSION}"
43+
log "Downloading Pact CLI standalone ${STANDALONE_VERSION}"
4444

4545
if [[ $(find "${STANDALONE_DIR}" -name "*${STANDALONE_VERSION}") ]]; then
46-
log "Skipping download of Ruby standalone, as it exists"
46+
log "Skipping download of Pact CLI standalone, as it exists"
4747
exit 0
4848
fi
4949

script/trigger-update.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ else
2727
echo "Release workflow triggered"
2828
fi
2929

30-
echo "https://github.com/${repository_slug}/actions?query=workflow%3A%22Update+Pact+Ruby+Standalone%22"
30+
echo "https://github.com/${repository_slug}/actions?query=workflow%3A%22Update+Pact+Standalone%22"

src/pact-standalone.spec.ts

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,17 @@ describe('Pact Standalone', function forMocha() {
3030
expect(pact.pactFullPath).to.contain('pact');
3131
expect(pact.pactflowPath).to.contain('pactflow');
3232
expect(pact.pactflowFullPath).to.contain('pactflow');
33+
34+
// Rust tools
35+
36+
expect(pact.mockServerPath).to.contain('pact_mock_server_cli');
37+
expect(pact.mockServerFullPath).to.contain('pact_mock_server_cli');
38+
expect(pact.verifierRustPath).to.contain('pact_verifier_cli');
39+
expect(pact.verifierRustFullPath).to.contain('pact_verifier_cli');
40+
expect(pact.stubServerPath).to.contain('pact-stub-serve');
41+
expect(pact.stubServerFullPath).to.contain('pact-stub-serve');
42+
expect(pact.pluginPath).to.contain('pact-plugin-cli');
43+
expect(pact.pluginFullPath).to.contain('pact-plugin-cli');
3344
});
3445

3546
it("should return the base directory of the project with 'cwd' (where the package.json file is)", () => {
@@ -99,6 +110,42 @@ describe('Pact Standalone', function forMocha() {
99110
expect(fs.existsSync(pact.pactflowFullPath)).to.be.true;
100111
});
101112

113+
it('mock server relative path', () => {
114+
expect(fs.existsSync(path.resolve(basePath, pact.mockServerPath))).to
115+
.be.true;
116+
});
117+
118+
it('mock server full path', () => {
119+
expect(fs.existsSync(pact.mockServerFullPath)).to.be.true;
120+
});
121+
122+
it('stub server relative path', () => {
123+
expect(fs.existsSync(path.resolve(basePath, pact.stubServerPath))).to
124+
.be.true;
125+
});
126+
127+
it('stub server full path', () => {
128+
expect(fs.existsSync(pact.stubServerFullPath)).to.be.true;
129+
});
130+
131+
it('rust verifier relative path', () => {
132+
expect(fs.existsSync(path.resolve(basePath, pact.verifierRustPath)))
133+
.to.be.true;
134+
});
135+
136+
it('rust verifier full path', () => {
137+
expect(fs.existsSync(pact.verifierRustFullPath)).to.be.true;
138+
});
139+
140+
it('plugin relative path', () => {
141+
expect(fs.existsSync(path.resolve(basePath, pact.pluginPath))).to.be
142+
.true;
143+
});
144+
145+
it('plugin full path', () => {
146+
expect(fs.existsSync(pact.pluginFullPath)).to.be.true;
147+
});
148+
102149
if (platform === 'win32') {
103150
it("should add '.bat' to the end of the binary names", () => {
104151
expect(pact.brokerPath).to.contain('pact-broker.bat');
@@ -118,6 +165,20 @@ describe('Pact Standalone', function forMocha() {
118165
expect(pact.pactflowPath).to.contain('pactflow.bat');
119166
expect(pact.pactflowFullPath).to.contain('pactflow.bat');
120167
});
168+
it("should add '.exe' to the end of the rust binary names", () => {
169+
expect(pact.mockServerPath).to.contain('pact_mock_server_cli.exe');
170+
expect(pact.mockServerFullPath).to.contain(
171+
'pact_mock_server_cli.exe'
172+
);
173+
expect(pact.stubServerPath).to.contain('pact-stub-server.exe');
174+
expect(pact.stubServerFullPath).to.contain('pact-stub-server.exe');
175+
expect(pact.verifierRustPath).to.contain('pact_verifier_cli.exe');
176+
expect(pact.verifierRustFullPath).to.contain(
177+
'pact_verifier_cli.exe'
178+
);
179+
expect(pact.pluginPath).to.contain('pact-plugin-cli.exe');
180+
expect(pact.pluginFullPath).to.contain('pact-plugin-cli.exe');
181+
});
121182
}
122183
});
123184
});

0 commit comments

Comments
 (0)