@pact-foundation/pact 10.0.0-beta.9 → 10.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2451 -1
- package/CODE_OF_CONDUCT.md +1 -1
- package/CONTRIBUTING.md +49 -12
- package/MIGRATION.md +77 -0
- package/README.md +180 -1274
- package/RELEASING.md +63 -59
- package/package.json +96 -98
- package/src/common/jsonTypes.d.ts +5 -0
- package/src/common/jsonTypes.js +3 -0
- package/src/common/jsonTypes.js.map +1 -0
- package/src/common/logger.d.ts +10 -0
- package/src/common/logger.js +32 -0
- package/src/common/logger.js.map +1 -0
- package/src/common/net.d.ts +9 -0
- package/src/common/net.js +82 -0
- package/src/common/net.js.map +1 -0
- package/{common → src/common}/net.spec.d.ts +0 -0
- package/src/common/net.spec.js +69 -0
- package/src/common/net.spec.js.map +1 -0
- package/src/common/request.d.ts +21 -0
- package/src/common/request.js +110 -0
- package/src/common/request.js.map +1 -0
- package/{common → src/common}/request.spec.d.ts +0 -0
- package/src/common/request.spec.js +69 -0
- package/src/common/request.spec.js.map +1 -0
- package/src/common/spec.d.ts +2 -0
- package/src/common/spec.js +22 -0
- package/src/common/spec.js.map +1 -0
- package/{dsl → src/dsl}/apolloGraphql.d.ts +1 -1
- package/{dsl → src/dsl}/apolloGraphql.js +4 -1
- package/src/dsl/apolloGraphql.js.map +1 -0
- package/{dsl → src/dsl}/apolloGraphql.spec.d.ts +0 -0
- package/src/dsl/apolloGraphql.spec.js +74 -0
- package/src/dsl/apolloGraphql.spec.js.map +1 -0
- package/{dsl → src/dsl}/graphql.d.ts +19 -8
- package/{dsl → src/dsl}/graphql.js +59 -31
- package/src/dsl/graphql.js.map +1 -0
- package/{dsl → src/dsl}/graphql.spec.d.ts +0 -0
- package/src/dsl/graphql.spec.js +229 -0
- package/src/dsl/graphql.spec.js.map +1 -0
- package/{dsl → src/dsl}/interaction.d.ts +22 -20
- package/src/dsl/interaction.js +144 -0
- package/src/dsl/interaction.js.map +1 -0
- package/{dsl → src/dsl}/interaction.spec.d.ts +0 -0
- package/src/dsl/interaction.spec.js +214 -0
- package/src/dsl/interaction.spec.js.map +1 -0
- package/src/dsl/matchers.d.ts +143 -0
- package/{dsl → src/dsl}/matchers.js +92 -93
- package/src/dsl/matchers.js.map +1 -0
- package/{dsl → src/dsl}/matchers.spec.d.ts +0 -0
- package/src/dsl/matchers.spec.js +668 -0
- package/src/dsl/matchers.spec.js.map +1 -0
- package/{dsl → src/dsl}/message.d.ts +32 -12
- package/{dsl → src/dsl}/message.js +0 -0
- package/{dsl → src/dsl}/message.js.map +1 -1
- package/src/dsl/mockService.d.ts +13 -0
- package/src/dsl/mockService.js +3 -0
- package/src/dsl/mockService.js.map +1 -0
- package/{dsl → src/dsl}/options.d.ts +7 -6
- package/{dsl → src/dsl}/options.js +0 -0
- package/{dsl → src/dsl}/options.js.map +1 -1
- package/src/dsl/verifier/index.d.ts +1 -0
- package/src/dsl/verifier/index.js +18 -0
- package/src/dsl/verifier/index.js.map +1 -0
- package/src/dsl/verifier/proxy/hooks.d.ts +4 -0
- package/src/dsl/verifier/proxy/hooks.js +109 -0
- package/src/dsl/verifier/proxy/hooks.js.map +1 -0
- package/src/dsl/verifier/proxy/index.d.ts +1 -0
- package/src/dsl/verifier/proxy/index.js +18 -0
- package/src/dsl/verifier/proxy/index.js.map +1 -0
- package/src/dsl/verifier/proxy/parseBody.d.ts +7 -0
- package/src/dsl/verifier/proxy/parseBody.js +22 -0
- package/src/dsl/verifier/proxy/parseBody.js.map +1 -0
- package/{dsl/mockService.spec.d.ts → src/dsl/verifier/proxy/parseBody.spec.d.ts} +0 -0
- package/src/dsl/verifier/proxy/parseBody.spec.js +118 -0
- package/src/dsl/verifier/proxy/parseBody.spec.js.map +1 -0
- package/src/dsl/verifier/proxy/proxy.d.ts +4 -0
- package/src/dsl/verifier/proxy/proxy.js +92 -0
- package/src/dsl/verifier/proxy/proxy.js.map +1 -0
- package/{dsl/publisher.spec.d.ts → src/dsl/verifier/proxy/proxy.spec.d.ts} +0 -0
- package/src/dsl/verifier/proxy/proxy.spec.js +33 -0
- package/src/dsl/verifier/proxy/proxy.spec.js.map +1 -0
- package/src/dsl/verifier/proxy/stateHandler/index.d.ts +1 -0
- package/src/dsl/verifier/proxy/stateHandler/index.js +18 -0
- package/src/dsl/verifier/proxy/stateHandler/index.js.map +1 -0
- package/src/dsl/verifier/proxy/stateHandler/setupStates.d.ts +3 -0
- package/src/dsl/verifier/proxy/stateHandler/setupStates.js +48 -0
- package/src/dsl/verifier/proxy/stateHandler/setupStates.js.map +1 -0
- package/{dsl/verifier.spec.d.ts → src/dsl/verifier/proxy/stateHandler/setupStates.spec.d.ts} +0 -0
- package/src/dsl/verifier/proxy/stateHandler/setupStates.spec.js +191 -0
- package/src/dsl/verifier/proxy/stateHandler/setupStates.spec.js.map +1 -0
- package/src/dsl/verifier/proxy/stateHandler/stateHandler.d.ts +3 -0
- package/src/dsl/verifier/proxy/stateHandler/stateHandler.js +14 -0
- package/src/dsl/verifier/proxy/stateHandler/stateHandler.js.map +1 -0
- package/{httpPact.spec.d.ts → src/dsl/verifier/proxy/stateHandler/stateHandler.spec.d.ts} +0 -0
- package/src/dsl/verifier/proxy/stateHandler/stateHandler.spec.js +130 -0
- package/src/dsl/verifier/proxy/stateHandler/stateHandler.spec.js.map +1 -0
- package/src/dsl/verifier/proxy/tracer.d.ts +3 -0
- package/src/dsl/verifier/proxy/tracer.js +52 -0
- package/src/dsl/verifier/proxy/tracer.js.map +1 -0
- package/src/dsl/verifier/proxy/types.d.ts +48 -0
- package/src/dsl/verifier/proxy/types.js +3 -0
- package/src/dsl/verifier/proxy/types.js.map +1 -0
- package/src/dsl/verifier/types.d.ts +3 -0
- package/src/dsl/verifier/types.js +3 -0
- package/src/dsl/verifier/types.js.map +1 -0
- package/src/dsl/verifier/verifier.d.ts +16 -0
- package/src/dsl/verifier/verifier.js +129 -0
- package/src/dsl/verifier/verifier.js.map +1 -0
- package/{messageConsumerPact.spec.d.ts → src/dsl/verifier/verifier.spec.d.ts} +0 -0
- package/src/dsl/verifier/verifier.spec.js +172 -0
- package/src/dsl/verifier/verifier.spec.js.map +1 -0
- package/{errors → src/errors}/configurationError.d.ts +0 -0
- package/{errors → src/errors}/configurationError.js +3 -1
- package/src/errors/configurationError.js.map +1 -0
- package/{errors → src/errors}/graphQLQueryError.d.ts +0 -0
- package/{errors → src/errors}/graphQLQueryError.js +3 -1
- package/src/errors/graphQLQueryError.js.map +1 -0
- package/{errors → src/errors}/matcherError.d.ts +0 -0
- package/{errors → src/errors}/matcherError.js +3 -1
- package/src/errors/matcherError.js.map +1 -0
- package/{errors → src/errors}/verificationError.d.ts +0 -0
- package/{errors → src/errors}/verificationError.js +3 -1
- package/src/errors/verificationError.js.map +1 -0
- package/src/httpPact/ffi.d.ts +15 -0
- package/src/httpPact/ffi.js +91 -0
- package/src/httpPact/ffi.js.map +1 -0
- package/{messageProviderPact.spec.d.ts → src/httpPact/ffi.spec.d.ts} +0 -0
- package/src/httpPact/ffi.spec.js +81 -0
- package/src/httpPact/ffi.spec.js.map +1 -0
- package/{httpPact.d.ts → src/httpPact/index.d.ts} +12 -12
- package/src/httpPact/index.js +311 -0
- package/src/httpPact/index.js.map +1 -0
- package/{pact-web.spec.d.ts → src/httpPact/index.spec.d.ts} +0 -0
- package/src/httpPact/index.spec.js +238 -0
- package/src/httpPact/index.spec.js.map +1 -0
- package/src/httpPact/tracing.d.ts +1 -0
- package/src/httpPact/tracing.js +53 -0
- package/src/httpPact/tracing.js.map +1 -0
- package/{pact.d.ts → src/index.d.ts} +22 -21
- package/src/index.js +107 -0
- package/src/index.js.map +1 -0
- package/src/messageConsumerPact.d.ts +86 -0
- package/src/messageConsumerPact.js +222 -0
- package/src/messageConsumerPact.js.map +1 -0
- package/src/messageConsumerPact.spec.d.ts +1 -0
- package/src/messageConsumerPact.spec.js +117 -0
- package/src/messageConsumerPact.spec.js.map +1 -0
- package/{messageProviderPact.d.ts → src/messageProviderPact.d.ts} +7 -4
- package/src/messageProviderPact.js +190 -0
- package/src/messageProviderPact.js.map +1 -0
- package/src/messageProviderPact.spec.d.ts +1 -0
- package/src/messageProviderPact.spec.js +183 -0
- package/src/messageProviderPact.spec.js.map +1 -0
- package/{pact.integration.spec.d.ts → src/pact.integration.spec.d.ts} +0 -0
- package/{pact.integration.spec.js → src/pact.integration.spec.js} +0 -0
- package/src/pact.integration.spec.js.map +1 -0
- package/src/v3/display.d.ts +6 -0
- package/src/v3/display.js +83 -0
- package/src/v3/display.js.map +1 -0
- package/src/v3/index.d.ts +17 -0
- package/src/v3/index.js +47 -0
- package/src/v3/index.js.map +1 -0
- package/src/v3/matchers.d.ts +182 -0
- package/src/v3/matchers.js +443 -0
- package/src/v3/matchers.js.map +1 -0
- package/src/v3/matchers.spec.d.ts +1 -0
- package/src/v3/matchers.spec.js +461 -0
- package/src/v3/matchers.spec.js.map +1 -0
- package/src/v3/pact.d.ts +21 -0
- package/src/v3/pact.js +240 -0
- package/src/v3/pact.js.map +1 -0
- package/src/v3/types.d.ts +81 -0
- package/src/v3/types.js +11 -0
- package/src/v3/types.js.map +1 -0
- package/{v3 → src/v3}/xml/xmlBuilder.d.ts +2 -2
- package/{v3 → src/v3}/xml/xmlBuilder.js +2 -1
- package/src/v3/xml/xmlBuilder.js.map +1 -0
- package/src/v3/xml/xmlElement.d.ts +27 -0
- package/{v3 → src/v3}/xml/xmlElement.js +21 -15
- package/src/v3/xml/xmlElement.js.map +1 -0
- package/src/v3/xml/xmlElement.spec.d.ts +1 -0
- package/src/v3/xml/xmlElement.spec.js +102 -0
- package/src/v3/xml/xmlElement.spec.js.map +1 -0
- package/{v3 → src/v3}/xml/xmlNode.d.ts +0 -0
- package/{v3 → src/v3}/xml/xmlNode.js +1 -0
- package/src/v3/xml/xmlNode.js.map +1 -0
- package/src/v3/xml/xmlText.d.ts +7 -0
- package/{v3 → src/v3}/xml/xmlText.js +4 -1
- package/src/v3/xml/xmlText.js.map +1 -0
- package/test/helper.d.ts +1 -0
- package/test/helper.js +37 -0
- package/test/helper.js.map +1 -0
- package/ROADMAP.md +0 -20
- package/common/logger.d.ts +0 -7
- package/common/logger.js +0 -56
- package/common/logger.js.map +0 -1
- package/common/metadata.d.ts +0 -0
- package/common/metadata.js +0 -2
- package/common/metadata.js.map +0 -1
- package/common/net.d.ts +0 -9
- package/common/net.js +0 -48
- package/common/net.js.map +0 -1
- package/common/net.spec.js +0 -67
- package/common/net.spec.js.map +0 -1
- package/common/request.d.ts +0 -14
- package/common/request.js +0 -47
- package/common/request.js.map +0 -1
- package/common/request.spec.js +0 -71
- package/common/request.spec.js.map +0 -1
- package/common/utils.d.ts +0 -2
- package/common/utils.js +0 -10
- package/common/utils.js.map +0 -1
- package/dsl/apolloGraphql.js.map +0 -1
- package/dsl/apolloGraphql.spec.js +0 -47
- package/dsl/apolloGraphql.spec.js.map +0 -1
- package/dsl/graphql.js.map +0 -1
- package/dsl/graphql.spec.js +0 -150
- package/dsl/graphql.spec.js.map +0 -1
- package/dsl/interaction.js +0 -112
- package/dsl/interaction.js.map +0 -1
- package/dsl/interaction.spec.js +0 -217
- package/dsl/interaction.spec.js.map +0 -1
- package/dsl/matchers.d.ts +0 -269
- package/dsl/matchers.js.map +0 -1
- package/dsl/matchers.spec.js +0 -563
- package/dsl/matchers.spec.js.map +0 -1
- package/dsl/mockService.d.ts +0 -58
- package/dsl/mockService.js +0 -74
- package/dsl/mockService.js.map +0 -1
- package/dsl/mockService.spec.js +0 -126
- package/dsl/mockService.spec.js.map +0 -1
- package/dsl/publisher.d.ts +0 -6
- package/dsl/publisher.js +0 -19
- package/dsl/publisher.js.map +0 -1
- package/dsl/publisher.spec.js +0 -21
- package/dsl/publisher.spec.js.map +0 -1
- package/dsl/verifier.d.ts +0 -39
- package/dsl/verifier.js +0 -173
- package/dsl/verifier.js.map +0 -1
- package/dsl/verifier.spec.js +0 -299
- package/dsl/verifier.spec.js.map +0 -1
- package/errors/configurationError.js.map +0 -1
- package/errors/graphQLQueryError.js.map +0 -1
- package/errors/matcherError.js.map +0 -1
- package/errors/verificationError.js.map +0 -1
- package/httpPact.js +0 -206
- package/httpPact.js.map +0 -1
- package/httpPact.spec.js +0 -337
- package/httpPact.spec.js.map +0 -1
- package/messageConsumerPact.d.ts +0 -67
- package/messageConsumerPact.js +0 -161
- package/messageConsumerPact.js.map +0 -1
- package/messageConsumerPact.spec.js +0 -161
- package/messageConsumerPact.spec.js.map +0 -1
- package/messageProviderPact.js +0 -139
- package/messageProviderPact.js.map +0 -1
- package/messageProviderPact.spec.js +0 -143
- package/messageProviderPact.spec.js.map +0 -1
- package/pact-web.d.ts +0 -100
- package/pact-web.js +0 -151
- package/pact-web.js.map +0 -1
- package/pact-web.spec.js +0 -191
- package/pact-web.spec.js.map +0 -1
- package/pact.integration.spec.js.map +0 -1
- package/pact.js +0 -74
- package/pact.js.map +0 -1
- package/v3/index.d.ts +0 -23
- package/v3/index.js +0 -33
- package/v3/index.js.map +0 -1
- package/v3/matchers.d.ts +0 -199
- package/v3/matchers.js +0 -305
- package/v3/matchers.js.map +0 -1
- package/v3/pact.d.ts +0 -47
- package/v3/pact.js +0 -101
- package/v3/pact.js.map +0 -1
- package/v3/verifier.d.ts +0 -27
- package/v3/verifier.js +0 -46
- package/v3/verifier.js.map +0 -1
- package/v3/xml/xmlBuilder.js.map +0 -1
- package/v3/xml/xmlElement.d.ts +0 -34
- package/v3/xml/xmlElement.js.map +0 -1
- package/v3/xml/xmlNode.js.map +0 -1
- package/v3/xml/xmlText.d.ts +0 -6
- package/v3/xml/xmlText.js.map +0 -1
package/RELEASING.md
CHANGED
|
@@ -1,84 +1,88 @@
|
|
|
1
1
|
# Releasing
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
We've moved to GitHub Actions for releases.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
- Commit
|
|
5
|
+
## How a release works
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
$ git push --follow-tags
|
|
7
|
+
Releases trigger when the repository recieves the custom repository_dispatch event
|
|
8
|
+
`release-triggered`.
|
|
11
9
|
|
|
12
|
-
|
|
10
|
+
This triggers the `publish.yml` workflow, which in turn
|
|
11
|
+
triggers the `release.sh` script in `scripts/ci`.
|
|
12
|
+
The workflow will also create a github release with an appropriate changelog.
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
Having the release triggered by a custom event is useful for automating
|
|
15
|
+
releases in the future (eg for version bumps in pact dependencies).
|
|
15
16
|
|
|
16
|
-
|
|
17
|
+
### Release.sh
|
|
17
18
|
|
|
18
|
-
|
|
19
|
+
This script is not intended to be run locally. Note that it modifies your git
|
|
20
|
+
settings.
|
|
19
21
|
|
|
20
|
-
|
|
22
|
+
The script will:
|
|
21
23
|
|
|
22
|
-
|
|
24
|
+
- Modify git authorship settings
|
|
25
|
+
- Confirm that there would be changes in the changelog after release
|
|
26
|
+
- Run Lint
|
|
27
|
+
- Run Build
|
|
28
|
+
- Run Test
|
|
29
|
+
- Commit an appropriate version bump, changelog and tag
|
|
30
|
+
- Package and publish to npm
|
|
31
|
+
- Push the new commit and tag back to the main branch.
|
|
23
32
|
|
|
24
|
-
|
|
33
|
+
Should you need to modify the script locally, you will find it uses some
|
|
34
|
+
dependencies in `scripts/ci/lib`.
|
|
25
35
|
|
|
26
|
-
|
|
36
|
+
## Kicking off a release
|
|
27
37
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
$ npm prune --production
|
|
31
|
-
$ tar -czvf pactjs.tar.gz config dist src package.json README.md LICENSE
|
|
32
|
-
$ npm run deploy:prepare
|
|
33
|
-
$ script: npm publish dist --access public
|
|
38
|
+
You must be able to create a github access token with `repo` scope to the
|
|
39
|
+
pact-js repository.
|
|
34
40
|
|
|
35
|
-
|
|
36
|
-
|
|
41
|
+
- Set an environment variable `GITHUB_ACCESS_TOKEN_FOR_PF_RELEASES` to this token.
|
|
42
|
+
- Make sure master contains the code you want to release
|
|
43
|
+
- Run `scripts/trigger-release.sh`
|
|
37
44
|
|
|
38
|
-
|
|
45
|
+
Then wait for github to do its magic. It will release the current head of master.
|
|
39
46
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
Echo the ~/.npmrc file and grab the token out of it.
|
|
47
|
+
Note that the release script refuses to publish anything that wouldn't
|
|
48
|
+
produce a changelog. Please make sure your commits follow the guidelines in
|
|
49
|
+
`CONTRIBUTING.md`
|
|
44
50
|
|
|
45
|
-
|
|
46
|
-
$ travis encrypt NPM_KEY=${NPM_KEY} --add env.global
|
|
51
|
+
## If the release fails
|
|
47
52
|
|
|
48
|
-
|
|
53
|
+
The publish is the second to last step, so if the release fails, you don't
|
|
54
|
+
need to do any rollbacks.
|
|
49
55
|
|
|
50
|
-
|
|
56
|
+
However, there is a potential for the push to fail _after_ a publish if there
|
|
57
|
+
are new commits to master since the release started. This is unlikely with
|
|
58
|
+
the current commit frequency, but could still happen. Check the logs to
|
|
59
|
+
determine if npm has a version that doesn't exist in the master branch.
|
|
51
60
|
|
|
52
|
-
|
|
61
|
+
If this has happened, you will need to manually put the release commit in.
|
|
53
62
|
|
|
54
|
-
To produce a darwin build, run from a Mac:
|
|
55
|
-
|
|
56
|
-
```
|
|
57
|
-
export NODE_PRE_GYP_GITHUB_TOKEN=<your github access token>
|
|
58
|
-
npm install node-pre-gyp node-pre-gyp-github
|
|
59
|
-
npm run build:v3
|
|
60
|
-
rm -rf native/target
|
|
61
|
-
npm run upload-binary
|
|
62
63
|
```
|
|
64
|
+
# First delete the new tag
|
|
65
|
+
# somehow this ends up in the repository
|
|
66
|
+
# even though the push fails.
|
|
63
67
|
|
|
64
|
-
|
|
68
|
+
git checkout master
|
|
69
|
+
git pull --tags
|
|
70
|
+
git tag -d <broken-version>
|
|
71
|
+
git push -delete origin <broken-version>
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
# If there are changes that introduce features, then you'll have to branch and probably rebase
|
|
75
|
+
|
|
76
|
+
# Now create a new commit + tag for the version:
|
|
77
|
+
npm run release
|
|
78
|
+
|
|
79
|
+
# Push that tag + commit
|
|
80
|
+
git push origin master --follow-tags
|
|
65
81
|
|
|
66
82
|
```
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
# choose 1 to progress
|
|
74
|
-
#
|
|
75
|
-
source $HOME/.cargo/env
|
|
76
|
-
export NODE_PRE_GYP_GITHUB_TOKEN=<your github access token>
|
|
77
|
-
cd /app
|
|
78
|
-
rm -rf node_modules build
|
|
79
|
-
npm ci
|
|
80
|
-
npm install node-pre-gyp node-pre-gyp-github
|
|
81
|
-
npm run build:v3
|
|
82
|
-
rm -rf native/target
|
|
83
|
-
npm run upload-binary
|
|
84
|
-
```
|
|
83
|
+
|
|
84
|
+
- Don't forget to create a new release in github.
|
|
85
|
+
|
|
86
|
+
Depending on the nature of the new commits to master after the release, you
|
|
87
|
+
may need to rebase them on top of the tagged release commit and force push (only do this
|
|
88
|
+
if the released version would be different to the version tagged by `npm run release`)
|
package/package.json
CHANGED
|
@@ -1,54 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pact-foundation/pact",
|
|
3
|
-
"version": "10.0.0
|
|
3
|
+
"version": "10.0.0",
|
|
4
4
|
"description": "Pact for all things Javascript",
|
|
5
|
-
"main": "./
|
|
6
|
-
"types": "./
|
|
5
|
+
"main": "./src/index.js",
|
|
6
|
+
"types": "./src/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"build": "npm run build:v2 && npm run build:v3",
|
|
9
|
-
"build:v2": "npm run lint && npm run compile",
|
|
10
|
-
"build:v3": "neon build --release",
|
|
11
8
|
"compile": "rimraf dist && tsc",
|
|
12
|
-
"clean": "rimraf docs dist
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"predist": "npm run clean && npm run lint && npm run jscpd",
|
|
25
|
-
"release": "standard-version -p beta",
|
|
26
|
-
"test": "nyc --check-coverage --reporter=html --reporter=text-summary mocha",
|
|
27
|
-
"test:examples": "npm run test:e2e-examples && npm run test:jest-examples && npm run test:mocha-examples && npm run test:ava-examples && npm run test:ts-examples && npm run test:message-examples && npm run test:serverless-examples && npm run test:graphql-examples",
|
|
28
|
-
"test:e2e-examples": "cd examples/e2e && npm it",
|
|
29
|
-
"test:ava-examples": "cd examples/ava && npm it",
|
|
30
|
-
"test:jest-examples": "cd examples/jest && npm it",
|
|
31
|
-
"test:mocha-examples": "cd examples/mocha && npm it",
|
|
32
|
-
"test:ts-examples": "cd examples/typescript && npm it",
|
|
33
|
-
"test:message-examples": "cd examples/messages && npm it",
|
|
34
|
-
"test:serverless-examples": "cd examples/serverless && npm it",
|
|
35
|
-
"test:graphql-examples": "cd examples/graphql && npm it",
|
|
36
|
-
"test:karma": "npm run test:karma:jasmine && npm run test:karma:mocha",
|
|
37
|
-
"test:karma:jasmine": "cd examples/karma && npm i && npm run test:jasmine",
|
|
38
|
-
"test:karma:mocha": "cd examples/karma && npm i && npm run test:mocha",
|
|
39
|
-
"travis": "./scripts/build.sh",
|
|
40
|
-
"appveyor": "./scripts/build.ps1",
|
|
41
|
-
"webpack": "webpack --config ./config/webpack.web.config.js",
|
|
42
|
-
"install": "node-pre-gyp install --fallback-to-build=false || neon build --release",
|
|
43
|
-
"package": "node-pre-gyp package",
|
|
44
|
-
"upload-binary": "npm run package && node-pre-gyp-github publish"
|
|
9
|
+
"clean": "rimraf docs dist coverage .nyc_output logs pacts",
|
|
10
|
+
"coverage": "nyc report --reporter=lcov",
|
|
11
|
+
"dist": "tsc && copyfiles package.json ./dist",
|
|
12
|
+
"lint": "eslint --config .eslintrc.json \"{src,test}/**/*.ts\"",
|
|
13
|
+
"lint:fix": "npm run lint -- --fix",
|
|
14
|
+
"format:base": "prettier \"{src,test,examples}/**/*.{ts,js}\"",
|
|
15
|
+
"format:fix": "npm run format:base -- --write",
|
|
16
|
+
"format:check": "npm run format:base -- --check",
|
|
17
|
+
"postdist": "npm test",
|
|
18
|
+
"predist": "npm run clean && npm run format:check && npm run lint",
|
|
19
|
+
"release": "standard-version -f",
|
|
20
|
+
"test": "nyc --check-coverage --reporter=html --reporter=text-summary mocha"
|
|
45
21
|
},
|
|
46
22
|
"repository": {
|
|
47
23
|
"type": "git",
|
|
48
24
|
"url": "git+https://github.com/pact-foundation/pact-js.git"
|
|
49
25
|
},
|
|
50
26
|
"engines": {
|
|
51
|
-
"node": ">=
|
|
27
|
+
"node": ">=10"
|
|
52
28
|
},
|
|
53
29
|
"keywords": [
|
|
54
30
|
"pact",
|
|
@@ -80,100 +56,122 @@
|
|
|
80
56
|
"bugs": {
|
|
81
57
|
"url": "https://github.com/pact-foundation/pact-js/issues"
|
|
82
58
|
},
|
|
83
|
-
"homepage": "
|
|
59
|
+
"homepage": "https://docs.pact.io/implementation_guides/javascript/",
|
|
60
|
+
"standard-version": {
|
|
61
|
+
"types": [
|
|
62
|
+
{
|
|
63
|
+
"type": "feat",
|
|
64
|
+
"section": "Features"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"type": "fix",
|
|
68
|
+
"section": "Fixes and Improvements"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"type": "chore",
|
|
72
|
+
"hidden": true
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"type": "docs",
|
|
76
|
+
"hidden": true
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"type": "style",
|
|
80
|
+
"hidden": true
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"type": "refactor",
|
|
84
|
+
"hidden": true
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"type": "perf",
|
|
88
|
+
"hidden": true
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"type": "test",
|
|
92
|
+
"hidden": true
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
},
|
|
84
96
|
"dependencies": {
|
|
85
|
-
"@pact-foundation/pact-
|
|
97
|
+
"@pact-foundation/pact-core": "^13.6.2",
|
|
86
98
|
"@types/bluebird": "^3.5.20",
|
|
87
|
-
"@types/
|
|
88
|
-
"
|
|
89
|
-
"@types/ramda": "^0.26.43",
|
|
99
|
+
"@types/express": "^4.17.11",
|
|
100
|
+
"axios": "^0.27.2",
|
|
90
101
|
"bluebird": "~3.5.1",
|
|
91
|
-
"body-parser": "^1.
|
|
92
|
-
"
|
|
93
|
-
"
|
|
94
|
-
"cli-color": "^1.1.0",
|
|
95
|
-
"es6-object-assign": "^1.1.0",
|
|
96
|
-
"es6-promise": "^4.1.1",
|
|
97
|
-
"express": "^4.16.3",
|
|
102
|
+
"body-parser": "^1.20.0",
|
|
103
|
+
"cli-color": "^2.0.1",
|
|
104
|
+
"express": "^4.18.1",
|
|
98
105
|
"graphql": "^14.0.0",
|
|
99
106
|
"graphql-tag": "^2.9.1",
|
|
100
107
|
"http-proxy": "^1.18.1",
|
|
101
|
-
"
|
|
102
|
-
"lodash": "^4.17.
|
|
108
|
+
"js-base64": "^3.6.1",
|
|
109
|
+
"lodash": "^4.17.21",
|
|
103
110
|
"lodash.isfunction": "3.0.8",
|
|
104
111
|
"lodash.isnil": "4.0.0",
|
|
105
112
|
"lodash.isundefined": "3.0.1",
|
|
106
113
|
"lodash.omit": "^4.5.0",
|
|
107
114
|
"lodash.omitby": "4.6.0",
|
|
108
|
-
"
|
|
109
|
-
"node-pre-gyp-github": "^1.4.3",
|
|
115
|
+
"pino-pretty": "^6.0.0",
|
|
110
116
|
"pkginfo": "^0.4.1",
|
|
111
|
-
"
|
|
112
|
-
"
|
|
117
|
+
"ramda": "^0.27.2",
|
|
118
|
+
"randexp": "^0.5.3"
|
|
113
119
|
},
|
|
114
120
|
"devDependencies": {
|
|
115
|
-
"@babel/cli": "
|
|
116
|
-
"@babel/core": "^7.6
|
|
117
|
-
"@babel/preset-env": "^7.6
|
|
118
|
-
"@
|
|
119
|
-
"@
|
|
121
|
+
"@babel/cli": "^7.18.6",
|
|
122
|
+
"@babel/core": "^7.18.6",
|
|
123
|
+
"@babel/preset-env": "^7.18.6",
|
|
124
|
+
"@octokit/rest": "^18.0.3",
|
|
125
|
+
"@pact-foundation/pact-js-prettier-config": "^1.0.0",
|
|
126
|
+
"@types/chai": "^4.3.1",
|
|
127
|
+
"@types/chai-as-promised": "^7.1.1",
|
|
120
128
|
"@types/cli-color": "^0.3.29",
|
|
121
|
-
"@types/
|
|
122
|
-
"@types/lodash": "^4.14.
|
|
123
|
-
"@types/lodash.isnil": "^4.0.
|
|
124
|
-
"@types/mocha": "^
|
|
129
|
+
"@types/http-proxy": "^1.17.9",
|
|
130
|
+
"@types/lodash": "^4.14.182",
|
|
131
|
+
"@types/lodash.isnil": "^4.0.7",
|
|
132
|
+
"@types/mocha": "^8.0.4",
|
|
133
|
+
"@types/mockery": "^1.4.29",
|
|
125
134
|
"@types/nock": "^9.1.2",
|
|
126
135
|
"@types/node": "^8.0.24",
|
|
127
|
-
"@types/
|
|
136
|
+
"@types/ramda": "^0.26.43",
|
|
128
137
|
"@types/sinon": "^7.0.6",
|
|
129
138
|
"@types/sinon-chai": "^2.7.29",
|
|
130
139
|
"@types/superagent": "^3.5.7",
|
|
131
140
|
"@types/tough-cookie": "^2.3.2",
|
|
132
141
|
"@types/underscore": "^1.8.5",
|
|
133
|
-
"
|
|
134
|
-
"
|
|
135
|
-
"babel-loader": "^8.0.6",
|
|
142
|
+
"@typescript-eslint/eslint-plugin": "^5.30.4",
|
|
143
|
+
"@typescript-eslint/parser": "^5.30.4",
|
|
136
144
|
"chai": "~4.1.2",
|
|
137
145
|
"chai-as-promised": "^7.1.1",
|
|
138
|
-
"
|
|
146
|
+
"copyfiles": "^2.4.1",
|
|
139
147
|
"enhanced-resolve": "^3.4.1",
|
|
140
|
-
"eslint": "^
|
|
141
|
-
"eslint-config-
|
|
142
|
-
"eslint-
|
|
143
|
-
"
|
|
144
|
-
"
|
|
148
|
+
"eslint": "^8.19.0",
|
|
149
|
+
"eslint-config-airbnb-base": "^15.0.0",
|
|
150
|
+
"eslint-config-prettier": "^8.5.0",
|
|
151
|
+
"eslint-import-resolver-typescript": "^3.2.1",
|
|
152
|
+
"eslint-plugin-chai-friendly": "^0.7.2",
|
|
153
|
+
"eslint-plugin-import": "^2.26.0",
|
|
154
|
+
"eslint-plugin-mocha": "^10.0.5",
|
|
155
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
145
156
|
"jasmine-core": "~2.9.1",
|
|
146
|
-
"jscpd": "0.6.22",
|
|
147
|
-
"json-loader": "~0.5.7",
|
|
148
|
-
"loader-utils": "^1.1.0",
|
|
149
157
|
"lodash.clone": "^4.5.0",
|
|
150
|
-
"mocha": "^
|
|
158
|
+
"mocha": "^9.1.1",
|
|
151
159
|
"mocha-lcov-reporter": "^1.3.0",
|
|
152
|
-
"
|
|
160
|
+
"mockery": "^2.1.0",
|
|
161
|
+
"neon-cli": "^0.9.1",
|
|
153
162
|
"nock": "^9.1.6",
|
|
154
|
-
"nyc": "^15.
|
|
155
|
-
"prettier": "^
|
|
163
|
+
"nyc": "^15.1.0",
|
|
164
|
+
"prettier": "^2.7.1",
|
|
156
165
|
"proxyquire": "^2.0.1",
|
|
157
166
|
"rimraf": "^2.7.1",
|
|
167
|
+
"sha256-file": "^1.0.0",
|
|
158
168
|
"sinon": "^7.2.4",
|
|
159
169
|
"sinon-chai": "^3.3.0",
|
|
160
|
-
"source-map-loader": "^0.2.1",
|
|
161
170
|
"source-map-support": "^0.4.18",
|
|
162
|
-
"standard-version": "^
|
|
171
|
+
"standard-version": "^9.5.0",
|
|
163
172
|
"superagent": "^3.8.2",
|
|
164
173
|
"ts-mock-imports": "^1.2.6",
|
|
165
174
|
"ts-node": "^3.3.0",
|
|
166
|
-
"
|
|
167
|
-
"tslint-config-prettier": "^1.15.0",
|
|
168
|
-
"typescript": "^3.8.3",
|
|
169
|
-
"webpack": "^3.5.5"
|
|
170
|
-
},
|
|
171
|
-
"binary": {
|
|
172
|
-
"module_name": "index",
|
|
173
|
-
"host": "https://github.com/pact-foundation/pact-js/releases/download/",
|
|
174
|
-
"remote_path": "v{version}",
|
|
175
|
-
"package_name": "{node_abi}-{platform}-{arch}.tar.gz",
|
|
176
|
-
"module_path": "./native",
|
|
177
|
-
"pkg_path": "."
|
|
175
|
+
"typescript": "^4.7.4"
|
|
178
176
|
}
|
|
179
177
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonTypes.js","sourceRoot":"","sources":["../../../src/common/jsonTypes.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from '@pact-foundation/pact-core/src/logger';
|
|
2
|
+
declare const _default: {
|
|
3
|
+
pactCrash: (message: string) => void;
|
|
4
|
+
error: (message: string) => void;
|
|
5
|
+
warn: (message: string) => void;
|
|
6
|
+
info: (message: string) => void;
|
|
7
|
+
debug: (message: string) => void;
|
|
8
|
+
trace: (message: string) => void;
|
|
9
|
+
};
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
var logger_1 = __importDefault(require("@pact-foundation/pact-core/src/logger"));
|
|
21
|
+
var package_json_1 = require("../../package.json");
|
|
22
|
+
__exportStar(require("@pact-foundation/pact-core/src/logger"), exports);
|
|
23
|
+
var context = "pact@".concat(package_json_1.version);
|
|
24
|
+
exports.default = {
|
|
25
|
+
pactCrash: function (message) { return logger_1.default.pactCrash(message, context); },
|
|
26
|
+
error: function (message) { return logger_1.default.error(message, context); },
|
|
27
|
+
warn: function (message) { return logger_1.default.warn(message, context); },
|
|
28
|
+
info: function (message) { return logger_1.default.info(message, context); },
|
|
29
|
+
debug: function (message) { return logger_1.default.debug(message, context); },
|
|
30
|
+
trace: function (message) { return logger_1.default.trace(message, context); },
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../src/common/logger.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,iFAA2D;AAE3D,mDAA6C;AAE7C,wEAAsD;AAEtD,IAAM,OAAO,GAAG,eAAQ,sBAAO,CAAE,CAAC;AAElC,kBAAe;IACb,SAAS,EAAE,UAAC,OAAe,IAAW,OAAA,gBAAM,CAAC,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,EAAlC,CAAkC;IACxE,KAAK,EAAE,UAAC,OAAe,IAAW,OAAA,gBAAM,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,EAA9B,CAA8B;IAChE,IAAI,EAAE,UAAC,OAAe,IAAW,OAAA,gBAAM,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,EAA7B,CAA6B;IAC9D,IAAI,EAAE,UAAC,OAAe,IAAW,OAAA,gBAAM,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,EAA7B,CAA6B;IAC9D,KAAK,EAAE,UAAC,OAAe,IAAW,OAAA,gBAAM,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,EAA9B,CAA8B;IAChE,KAAK,EAAE,UAAC,OAAe,IAAW,OAAA,gBAAM,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,EAA9B,CAA8B;CACjE,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Network module.
|
|
3
|
+
* @module net
|
|
4
|
+
* @private
|
|
5
|
+
*/
|
|
6
|
+
export declare const localAddresses: string[];
|
|
7
|
+
export declare const portCheck: (port: number, host: string) => Promise<void>;
|
|
8
|
+
export declare const isPortAvailable: (port: number, host: string) => Promise<void>;
|
|
9
|
+
export declare const freePort: () => Promise<number>;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Network module.
|
|
4
|
+
* @module net
|
|
5
|
+
* @private
|
|
6
|
+
*/
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
+
}) : function(o, v) {
|
|
21
|
+
o["default"] = v;
|
|
22
|
+
});
|
|
23
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
24
|
+
if (mod && mod.__esModule) return mod;
|
|
25
|
+
var result = {};
|
|
26
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
27
|
+
__setModuleDefault(result, mod);
|
|
28
|
+
return result;
|
|
29
|
+
};
|
|
30
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
+
exports.freePort = exports.isPortAvailable = exports.portCheck = exports.localAddresses = void 0;
|
|
32
|
+
var net = __importStar(require("net"));
|
|
33
|
+
var bluebird_1 = require("bluebird");
|
|
34
|
+
exports.localAddresses = ['127.0.0.1', 'localhost', '0.0.0.0', '::1'];
|
|
35
|
+
var portCheck = function (port, host) {
|
|
36
|
+
return new Promise(function (resolve, reject) {
|
|
37
|
+
var server = net
|
|
38
|
+
.createServer()
|
|
39
|
+
.listen({ port: port, host: host, exclusive: true })
|
|
40
|
+
.on('error', function (e) {
|
|
41
|
+
if (e.code === 'EADDRINUSE') {
|
|
42
|
+
reject(new Error("Port ".concat(port, " is unavailable on address ").concat(host)));
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
reject(e);
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
.on('listening', function () {
|
|
49
|
+
server.once('close', function () { return resolve(); }).close();
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
exports.portCheck = portCheck;
|
|
54
|
+
var isPortAvailable = function (port, host) {
|
|
55
|
+
return Promise.resolve(bluebird_1.Promise
|
|
56
|
+
.map(exports.localAddresses,
|
|
57
|
+
// we meed to wrap the built-in Promise with bluebird.reflect() so we can
|
|
58
|
+
// test the result of the promise without failing bluebird.map()
|
|
59
|
+
function (h) { return bluebird_1.Promise.resolve((0, exports.portCheck)(port, h)).reflect(); },
|
|
60
|
+
// do each port check sequentially (as localhost & 127.0.0.1 will conflict on most default environments)
|
|
61
|
+
{ concurrency: 1 })
|
|
62
|
+
.then(function (inspections) {
|
|
63
|
+
// if every port check failed, then fail the `isPortAvailable` check
|
|
64
|
+
if (inspections.every(function (inspection) { return !inspection.isFulfilled(); })) {
|
|
65
|
+
return Promise.reject(new Error("Cannot open port ".concat(port, " on ipv4 or ipv6 interfaces")));
|
|
66
|
+
}
|
|
67
|
+
// the local addresses passed - now check the host that the user has specified
|
|
68
|
+
return (0, exports.portCheck)(port, host);
|
|
69
|
+
}));
|
|
70
|
+
};
|
|
71
|
+
exports.isPortAvailable = isPortAvailable;
|
|
72
|
+
var freePort = function () {
|
|
73
|
+
return new Promise(function (res) {
|
|
74
|
+
var s = net.createServer();
|
|
75
|
+
s.listen(0, function () {
|
|
76
|
+
var port = s.address().port;
|
|
77
|
+
s.close(function () { return res(port); });
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
exports.freePort = freePort;
|
|
82
|
+
//# sourceMappingURL=net.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"net.js","sourceRoot":"","sources":["../../../src/common/net.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAA2B;AAC3B,qCAA+C;AAElC,QAAA,cAAc,GAAG,CAAC,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;AAEpE,IAAM,SAAS,GAAG,UAAC,IAAY,EAAE,IAAY;IAClD,OAAA,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;QAC1B,IAAM,MAAM,GAAG,GAAG;aACf,YAAY,EAAE;aACd,MAAM,CAAC,EAAE,IAAI,MAAA,EAAE,IAAI,MAAA,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;aACvC,EAAE,CAAC,OAAO,EAAE,UAAC,CAAwB;YACpC,IAAI,CAAC,CAAC,IAAI,KAAK,YAAY,EAAE;gBAC3B,MAAM,CAAC,IAAI,KAAK,CAAC,eAAQ,IAAI,wCAA8B,IAAI,CAAE,CAAC,CAAC,CAAC;aACrE;iBAAM;gBACL,MAAM,CAAC,CAAC,CAAC,CAAC;aACX;QACH,CAAC,CAAC;aACD,EAAE,CAAC,WAAW,EAAE;YACf,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,cAAM,OAAA,OAAO,EAAE,EAAT,CAAS,CAAC,CAAC,KAAK,EAAE,CAAC;QAChD,CAAC,CAAC,CAAC;IACP,CAAC,CAAC;AAdF,CAcE,CAAC;AAfQ,QAAA,SAAS,aAejB;AAEE,IAAM,eAAe,GAAG,UAAC,IAAY,EAAE,IAAY;IACxD,OAAA,OAAO,CAAC,OAAO,CACb,kBAAQ;SACL,GAAG,CACF,sBAAc;IACd,yEAAyE;IACzE,gEAAgE;IAChE,UAAC,CAAC,IAAK,OAAA,kBAAQ,CAAC,OAAO,CAAC,IAAA,iBAAS,EAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,EAA9C,CAA8C;IACrD,wGAAwG;IACxG,EAAE,WAAW,EAAE,CAAC,EAAE,CACnB;SACA,IAAI,CAAC,UAAC,WAAW;QAChB,oEAAoE;QACpE,IAAI,WAAW,CAAC,KAAK,CAAC,UAAC,UAAU,IAAK,OAAA,CAAC,UAAU,CAAC,WAAW,EAAE,EAAzB,CAAyB,CAAC,EAAE;YAChE,OAAO,OAAO,CAAC,MAAM,CACnB,IAAI,KAAK,CAAC,2BAAoB,IAAI,gCAA6B,CAAC,CACjE,CAAC;SACH;QAED,8EAA8E;QAC9E,OAAO,IAAA,iBAAS,EAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC/B,CAAC,CAAC,CACL;AArBD,CAqBC,CAAC;AAtBS,QAAA,eAAe,mBAsBxB;AAEG,IAAM,QAAQ,GAAG;IACtB,OAAO,IAAI,OAAO,CAAC,UAAC,GAAG;QACrB,IAAM,CAAC,GAAG,GAAG,CAAC,YAAY,EAAE,CAAC;QAC7B,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE;YACV,IAAM,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC;YAC9B,CAAC,CAAC,KAAK,CAAC,cAAM,OAAA,GAAG,CAAC,IAAI,CAAC,EAAT,CAAS,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AARW,QAAA,QAAQ,YAQnB"}
|
|
File without changes
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var chai_1 = __importDefault(require("chai"));
|
|
7
|
+
var chai_as_promised_1 = __importDefault(require("chai-as-promised"));
|
|
8
|
+
var net_1 = __importDefault(require("net"));
|
|
9
|
+
var net_2 = require("./net");
|
|
10
|
+
var logger_1 = __importDefault(require("./logger"));
|
|
11
|
+
var expect = chai_1.default.expect;
|
|
12
|
+
chai_1.default.use(chai_as_promised_1.default);
|
|
13
|
+
describe('Net', function () {
|
|
14
|
+
var port = 4567;
|
|
15
|
+
var defaultHost = '0.0.0.0';
|
|
16
|
+
var specialPort = process.platform.match('win') ? -1 : 80;
|
|
17
|
+
// Utility function to create a server on a given port and return a Promise
|
|
18
|
+
var createServer = function (p, host) {
|
|
19
|
+
if (host === void 0) { host = defaultHost; }
|
|
20
|
+
return new Promise(function (resolve, reject) {
|
|
21
|
+
var server = net_1.default.createServer();
|
|
22
|
+
server.on('error', function (err) { return reject(err); });
|
|
23
|
+
server.on('listening', function () { return resolve(server); });
|
|
24
|
+
server.listen({ port: p, host: host, exclusive: true }, function () {
|
|
25
|
+
logger_1.default.info("test server is up on ".concat(host, ":").concat(p));
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
describe('#isPortAvailable', function () {
|
|
30
|
+
context('when the port is not allowed to be bound', function () {
|
|
31
|
+
it('returns a rejected promise', function () {
|
|
32
|
+
return expect((0, net_2.isPortAvailable)(specialPort, defaultHost)).to.eventually.be
|
|
33
|
+
.rejected;
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
context('when the port is available', function () {
|
|
37
|
+
it('returns a fulfilled promise', function () {
|
|
38
|
+
return expect((0, net_2.isPortAvailable)(port, defaultHost)).to.eventually.be.fulfilled;
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
context('when the port is unavailable', function () {
|
|
42
|
+
var closeFn = function (cb) { return cb(); };
|
|
43
|
+
it('returns a rejected promise', function () {
|
|
44
|
+
return createServer(port).then(function (server) {
|
|
45
|
+
closeFn = server.close.bind(server);
|
|
46
|
+
return expect((0, net_2.isPortAvailable)(port, defaultHost)).to.eventually.be
|
|
47
|
+
.rejected;
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
// close the servers used in this test as to not conflict with other tests
|
|
51
|
+
afterEach(function (done) { return closeFn(done); });
|
|
52
|
+
});
|
|
53
|
+
context('when a single host is unavailable', function () {
|
|
54
|
+
var closeFn = function (cb) { return cb(); };
|
|
55
|
+
it('returns a fulfilled promise', function () {
|
|
56
|
+
// simulate ::1 being unavailable
|
|
57
|
+
return createServer(port, '::1').then(function (server) {
|
|
58
|
+
closeFn = server.close.bind(server);
|
|
59
|
+
// this should work as the `127.0.0.1` is NOT `::1`
|
|
60
|
+
return expect((0, net_2.isPortAvailable)(port, '127.0.0.1')).to.eventually.be
|
|
61
|
+
.fulfilled;
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
// close the servers used in this test as to not conflict with other tests
|
|
65
|
+
afterEach(function (done) { return closeFn(done); });
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
//# sourceMappingURL=net.spec.js.map
|