@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.
Files changed (285) hide show
  1. package/CHANGELOG.md +2451 -1
  2. package/CODE_OF_CONDUCT.md +1 -1
  3. package/CONTRIBUTING.md +49 -12
  4. package/MIGRATION.md +77 -0
  5. package/README.md +180 -1274
  6. package/RELEASING.md +63 -59
  7. package/package.json +96 -98
  8. package/src/common/jsonTypes.d.ts +5 -0
  9. package/src/common/jsonTypes.js +3 -0
  10. package/src/common/jsonTypes.js.map +1 -0
  11. package/src/common/logger.d.ts +10 -0
  12. package/src/common/logger.js +32 -0
  13. package/src/common/logger.js.map +1 -0
  14. package/src/common/net.d.ts +9 -0
  15. package/src/common/net.js +82 -0
  16. package/src/common/net.js.map +1 -0
  17. package/{common → src/common}/net.spec.d.ts +0 -0
  18. package/src/common/net.spec.js +69 -0
  19. package/src/common/net.spec.js.map +1 -0
  20. package/src/common/request.d.ts +21 -0
  21. package/src/common/request.js +110 -0
  22. package/src/common/request.js.map +1 -0
  23. package/{common → src/common}/request.spec.d.ts +0 -0
  24. package/src/common/request.spec.js +69 -0
  25. package/src/common/request.spec.js.map +1 -0
  26. package/src/common/spec.d.ts +2 -0
  27. package/src/common/spec.js +22 -0
  28. package/src/common/spec.js.map +1 -0
  29. package/{dsl → src/dsl}/apolloGraphql.d.ts +1 -1
  30. package/{dsl → src/dsl}/apolloGraphql.js +4 -1
  31. package/src/dsl/apolloGraphql.js.map +1 -0
  32. package/{dsl → src/dsl}/apolloGraphql.spec.d.ts +0 -0
  33. package/src/dsl/apolloGraphql.spec.js +74 -0
  34. package/src/dsl/apolloGraphql.spec.js.map +1 -0
  35. package/{dsl → src/dsl}/graphql.d.ts +19 -8
  36. package/{dsl → src/dsl}/graphql.js +59 -31
  37. package/src/dsl/graphql.js.map +1 -0
  38. package/{dsl → src/dsl}/graphql.spec.d.ts +0 -0
  39. package/src/dsl/graphql.spec.js +229 -0
  40. package/src/dsl/graphql.spec.js.map +1 -0
  41. package/{dsl → src/dsl}/interaction.d.ts +22 -20
  42. package/src/dsl/interaction.js +144 -0
  43. package/src/dsl/interaction.js.map +1 -0
  44. package/{dsl → src/dsl}/interaction.spec.d.ts +0 -0
  45. package/src/dsl/interaction.spec.js +214 -0
  46. package/src/dsl/interaction.spec.js.map +1 -0
  47. package/src/dsl/matchers.d.ts +143 -0
  48. package/{dsl → src/dsl}/matchers.js +92 -93
  49. package/src/dsl/matchers.js.map +1 -0
  50. package/{dsl → src/dsl}/matchers.spec.d.ts +0 -0
  51. package/src/dsl/matchers.spec.js +668 -0
  52. package/src/dsl/matchers.spec.js.map +1 -0
  53. package/{dsl → src/dsl}/message.d.ts +32 -12
  54. package/{dsl → src/dsl}/message.js +0 -0
  55. package/{dsl → src/dsl}/message.js.map +1 -1
  56. package/src/dsl/mockService.d.ts +13 -0
  57. package/src/dsl/mockService.js +3 -0
  58. package/src/dsl/mockService.js.map +1 -0
  59. package/{dsl → src/dsl}/options.d.ts +7 -6
  60. package/{dsl → src/dsl}/options.js +0 -0
  61. package/{dsl → src/dsl}/options.js.map +1 -1
  62. package/src/dsl/verifier/index.d.ts +1 -0
  63. package/src/dsl/verifier/index.js +18 -0
  64. package/src/dsl/verifier/index.js.map +1 -0
  65. package/src/dsl/verifier/proxy/hooks.d.ts +4 -0
  66. package/src/dsl/verifier/proxy/hooks.js +109 -0
  67. package/src/dsl/verifier/proxy/hooks.js.map +1 -0
  68. package/src/dsl/verifier/proxy/index.d.ts +1 -0
  69. package/src/dsl/verifier/proxy/index.js +18 -0
  70. package/src/dsl/verifier/proxy/index.js.map +1 -0
  71. package/src/dsl/verifier/proxy/parseBody.d.ts +7 -0
  72. package/src/dsl/verifier/proxy/parseBody.js +22 -0
  73. package/src/dsl/verifier/proxy/parseBody.js.map +1 -0
  74. package/{dsl/mockService.spec.d.ts → src/dsl/verifier/proxy/parseBody.spec.d.ts} +0 -0
  75. package/src/dsl/verifier/proxy/parseBody.spec.js +118 -0
  76. package/src/dsl/verifier/proxy/parseBody.spec.js.map +1 -0
  77. package/src/dsl/verifier/proxy/proxy.d.ts +4 -0
  78. package/src/dsl/verifier/proxy/proxy.js +92 -0
  79. package/src/dsl/verifier/proxy/proxy.js.map +1 -0
  80. package/{dsl/publisher.spec.d.ts → src/dsl/verifier/proxy/proxy.spec.d.ts} +0 -0
  81. package/src/dsl/verifier/proxy/proxy.spec.js +33 -0
  82. package/src/dsl/verifier/proxy/proxy.spec.js.map +1 -0
  83. package/src/dsl/verifier/proxy/stateHandler/index.d.ts +1 -0
  84. package/src/dsl/verifier/proxy/stateHandler/index.js +18 -0
  85. package/src/dsl/verifier/proxy/stateHandler/index.js.map +1 -0
  86. package/src/dsl/verifier/proxy/stateHandler/setupStates.d.ts +3 -0
  87. package/src/dsl/verifier/proxy/stateHandler/setupStates.js +48 -0
  88. package/src/dsl/verifier/proxy/stateHandler/setupStates.js.map +1 -0
  89. package/{dsl/verifier.spec.d.ts → src/dsl/verifier/proxy/stateHandler/setupStates.spec.d.ts} +0 -0
  90. package/src/dsl/verifier/proxy/stateHandler/setupStates.spec.js +191 -0
  91. package/src/dsl/verifier/proxy/stateHandler/setupStates.spec.js.map +1 -0
  92. package/src/dsl/verifier/proxy/stateHandler/stateHandler.d.ts +3 -0
  93. package/src/dsl/verifier/proxy/stateHandler/stateHandler.js +14 -0
  94. package/src/dsl/verifier/proxy/stateHandler/stateHandler.js.map +1 -0
  95. package/{httpPact.spec.d.ts → src/dsl/verifier/proxy/stateHandler/stateHandler.spec.d.ts} +0 -0
  96. package/src/dsl/verifier/proxy/stateHandler/stateHandler.spec.js +130 -0
  97. package/src/dsl/verifier/proxy/stateHandler/stateHandler.spec.js.map +1 -0
  98. package/src/dsl/verifier/proxy/tracer.d.ts +3 -0
  99. package/src/dsl/verifier/proxy/tracer.js +52 -0
  100. package/src/dsl/verifier/proxy/tracer.js.map +1 -0
  101. package/src/dsl/verifier/proxy/types.d.ts +48 -0
  102. package/src/dsl/verifier/proxy/types.js +3 -0
  103. package/src/dsl/verifier/proxy/types.js.map +1 -0
  104. package/src/dsl/verifier/types.d.ts +3 -0
  105. package/src/dsl/verifier/types.js +3 -0
  106. package/src/dsl/verifier/types.js.map +1 -0
  107. package/src/dsl/verifier/verifier.d.ts +16 -0
  108. package/src/dsl/verifier/verifier.js +129 -0
  109. package/src/dsl/verifier/verifier.js.map +1 -0
  110. package/{messageConsumerPact.spec.d.ts → src/dsl/verifier/verifier.spec.d.ts} +0 -0
  111. package/src/dsl/verifier/verifier.spec.js +172 -0
  112. package/src/dsl/verifier/verifier.spec.js.map +1 -0
  113. package/{errors → src/errors}/configurationError.d.ts +0 -0
  114. package/{errors → src/errors}/configurationError.js +3 -1
  115. package/src/errors/configurationError.js.map +1 -0
  116. package/{errors → src/errors}/graphQLQueryError.d.ts +0 -0
  117. package/{errors → src/errors}/graphQLQueryError.js +3 -1
  118. package/src/errors/graphQLQueryError.js.map +1 -0
  119. package/{errors → src/errors}/matcherError.d.ts +0 -0
  120. package/{errors → src/errors}/matcherError.js +3 -1
  121. package/src/errors/matcherError.js.map +1 -0
  122. package/{errors → src/errors}/verificationError.d.ts +0 -0
  123. package/{errors → src/errors}/verificationError.js +3 -1
  124. package/src/errors/verificationError.js.map +1 -0
  125. package/src/httpPact/ffi.d.ts +15 -0
  126. package/src/httpPact/ffi.js +91 -0
  127. package/src/httpPact/ffi.js.map +1 -0
  128. package/{messageProviderPact.spec.d.ts → src/httpPact/ffi.spec.d.ts} +0 -0
  129. package/src/httpPact/ffi.spec.js +81 -0
  130. package/src/httpPact/ffi.spec.js.map +1 -0
  131. package/{httpPact.d.ts → src/httpPact/index.d.ts} +12 -12
  132. package/src/httpPact/index.js +311 -0
  133. package/src/httpPact/index.js.map +1 -0
  134. package/{pact-web.spec.d.ts → src/httpPact/index.spec.d.ts} +0 -0
  135. package/src/httpPact/index.spec.js +238 -0
  136. package/src/httpPact/index.spec.js.map +1 -0
  137. package/src/httpPact/tracing.d.ts +1 -0
  138. package/src/httpPact/tracing.js +53 -0
  139. package/src/httpPact/tracing.js.map +1 -0
  140. package/{pact.d.ts → src/index.d.ts} +22 -21
  141. package/src/index.js +107 -0
  142. package/src/index.js.map +1 -0
  143. package/src/messageConsumerPact.d.ts +86 -0
  144. package/src/messageConsumerPact.js +222 -0
  145. package/src/messageConsumerPact.js.map +1 -0
  146. package/src/messageConsumerPact.spec.d.ts +1 -0
  147. package/src/messageConsumerPact.spec.js +117 -0
  148. package/src/messageConsumerPact.spec.js.map +1 -0
  149. package/{messageProviderPact.d.ts → src/messageProviderPact.d.ts} +7 -4
  150. package/src/messageProviderPact.js +190 -0
  151. package/src/messageProviderPact.js.map +1 -0
  152. package/src/messageProviderPact.spec.d.ts +1 -0
  153. package/src/messageProviderPact.spec.js +183 -0
  154. package/src/messageProviderPact.spec.js.map +1 -0
  155. package/{pact.integration.spec.d.ts → src/pact.integration.spec.d.ts} +0 -0
  156. package/{pact.integration.spec.js → src/pact.integration.spec.js} +0 -0
  157. package/src/pact.integration.spec.js.map +1 -0
  158. package/src/v3/display.d.ts +6 -0
  159. package/src/v3/display.js +83 -0
  160. package/src/v3/display.js.map +1 -0
  161. package/src/v3/index.d.ts +17 -0
  162. package/src/v3/index.js +47 -0
  163. package/src/v3/index.js.map +1 -0
  164. package/src/v3/matchers.d.ts +182 -0
  165. package/src/v3/matchers.js +443 -0
  166. package/src/v3/matchers.js.map +1 -0
  167. package/src/v3/matchers.spec.d.ts +1 -0
  168. package/src/v3/matchers.spec.js +461 -0
  169. package/src/v3/matchers.spec.js.map +1 -0
  170. package/src/v3/pact.d.ts +21 -0
  171. package/src/v3/pact.js +240 -0
  172. package/src/v3/pact.js.map +1 -0
  173. package/src/v3/types.d.ts +81 -0
  174. package/src/v3/types.js +11 -0
  175. package/src/v3/types.js.map +1 -0
  176. package/{v3 → src/v3}/xml/xmlBuilder.d.ts +2 -2
  177. package/{v3 → src/v3}/xml/xmlBuilder.js +2 -1
  178. package/src/v3/xml/xmlBuilder.js.map +1 -0
  179. package/src/v3/xml/xmlElement.d.ts +27 -0
  180. package/{v3 → src/v3}/xml/xmlElement.js +21 -15
  181. package/src/v3/xml/xmlElement.js.map +1 -0
  182. package/src/v3/xml/xmlElement.spec.d.ts +1 -0
  183. package/src/v3/xml/xmlElement.spec.js +102 -0
  184. package/src/v3/xml/xmlElement.spec.js.map +1 -0
  185. package/{v3 → src/v3}/xml/xmlNode.d.ts +0 -0
  186. package/{v3 → src/v3}/xml/xmlNode.js +1 -0
  187. package/src/v3/xml/xmlNode.js.map +1 -0
  188. package/src/v3/xml/xmlText.d.ts +7 -0
  189. package/{v3 → src/v3}/xml/xmlText.js +4 -1
  190. package/src/v3/xml/xmlText.js.map +1 -0
  191. package/test/helper.d.ts +1 -0
  192. package/test/helper.js +37 -0
  193. package/test/helper.js.map +1 -0
  194. package/ROADMAP.md +0 -20
  195. package/common/logger.d.ts +0 -7
  196. package/common/logger.js +0 -56
  197. package/common/logger.js.map +0 -1
  198. package/common/metadata.d.ts +0 -0
  199. package/common/metadata.js +0 -2
  200. package/common/metadata.js.map +0 -1
  201. package/common/net.d.ts +0 -9
  202. package/common/net.js +0 -48
  203. package/common/net.js.map +0 -1
  204. package/common/net.spec.js +0 -67
  205. package/common/net.spec.js.map +0 -1
  206. package/common/request.d.ts +0 -14
  207. package/common/request.js +0 -47
  208. package/common/request.js.map +0 -1
  209. package/common/request.spec.js +0 -71
  210. package/common/request.spec.js.map +0 -1
  211. package/common/utils.d.ts +0 -2
  212. package/common/utils.js +0 -10
  213. package/common/utils.js.map +0 -1
  214. package/dsl/apolloGraphql.js.map +0 -1
  215. package/dsl/apolloGraphql.spec.js +0 -47
  216. package/dsl/apolloGraphql.spec.js.map +0 -1
  217. package/dsl/graphql.js.map +0 -1
  218. package/dsl/graphql.spec.js +0 -150
  219. package/dsl/graphql.spec.js.map +0 -1
  220. package/dsl/interaction.js +0 -112
  221. package/dsl/interaction.js.map +0 -1
  222. package/dsl/interaction.spec.js +0 -217
  223. package/dsl/interaction.spec.js.map +0 -1
  224. package/dsl/matchers.d.ts +0 -269
  225. package/dsl/matchers.js.map +0 -1
  226. package/dsl/matchers.spec.js +0 -563
  227. package/dsl/matchers.spec.js.map +0 -1
  228. package/dsl/mockService.d.ts +0 -58
  229. package/dsl/mockService.js +0 -74
  230. package/dsl/mockService.js.map +0 -1
  231. package/dsl/mockService.spec.js +0 -126
  232. package/dsl/mockService.spec.js.map +0 -1
  233. package/dsl/publisher.d.ts +0 -6
  234. package/dsl/publisher.js +0 -19
  235. package/dsl/publisher.js.map +0 -1
  236. package/dsl/publisher.spec.js +0 -21
  237. package/dsl/publisher.spec.js.map +0 -1
  238. package/dsl/verifier.d.ts +0 -39
  239. package/dsl/verifier.js +0 -173
  240. package/dsl/verifier.js.map +0 -1
  241. package/dsl/verifier.spec.js +0 -299
  242. package/dsl/verifier.spec.js.map +0 -1
  243. package/errors/configurationError.js.map +0 -1
  244. package/errors/graphQLQueryError.js.map +0 -1
  245. package/errors/matcherError.js.map +0 -1
  246. package/errors/verificationError.js.map +0 -1
  247. package/httpPact.js +0 -206
  248. package/httpPact.js.map +0 -1
  249. package/httpPact.spec.js +0 -337
  250. package/httpPact.spec.js.map +0 -1
  251. package/messageConsumerPact.d.ts +0 -67
  252. package/messageConsumerPact.js +0 -161
  253. package/messageConsumerPact.js.map +0 -1
  254. package/messageConsumerPact.spec.js +0 -161
  255. package/messageConsumerPact.spec.js.map +0 -1
  256. package/messageProviderPact.js +0 -139
  257. package/messageProviderPact.js.map +0 -1
  258. package/messageProviderPact.spec.js +0 -143
  259. package/messageProviderPact.spec.js.map +0 -1
  260. package/pact-web.d.ts +0 -100
  261. package/pact-web.js +0 -151
  262. package/pact-web.js.map +0 -1
  263. package/pact-web.spec.js +0 -191
  264. package/pact-web.spec.js.map +0 -1
  265. package/pact.integration.spec.js.map +0 -1
  266. package/pact.js +0 -74
  267. package/pact.js.map +0 -1
  268. package/v3/index.d.ts +0 -23
  269. package/v3/index.js +0 -33
  270. package/v3/index.js.map +0 -1
  271. package/v3/matchers.d.ts +0 -199
  272. package/v3/matchers.js +0 -305
  273. package/v3/matchers.js.map +0 -1
  274. package/v3/pact.d.ts +0 -47
  275. package/v3/pact.js +0 -101
  276. package/v3/pact.js.map +0 -1
  277. package/v3/verifier.d.ts +0 -27
  278. package/v3/verifier.js +0 -46
  279. package/v3/verifier.js.map +0 -1
  280. package/v3/xml/xmlBuilder.js.map +0 -1
  281. package/v3/xml/xmlElement.d.ts +0 -34
  282. package/v3/xml/xmlElement.js.map +0 -1
  283. package/v3/xml/xmlNode.js.map +0 -1
  284. package/v3/xml/xmlText.d.ts +0 -6
  285. package/v3/xml/xmlText.js.map +0 -1
package/RELEASING.md CHANGED
@@ -1,84 +1,88 @@
1
1
  # Releasing
2
2
 
3
- ## Publishing via Travis (recommended)
3
+ We've moved to GitHub Actions for releases.
4
4
 
5
- - Update the version number in each `package.json` file to latest version
6
- - Commit
5
+ ## How a release works
7
6
 
8
- $ npm run release
9
- $ # review workspace and commits - if all looks good...
10
- $ git push --follow-tags
7
+ Releases trigger when the repository recieves the custom repository_dispatch event
8
+ `release-triggered`.
11
9
 
12
- Travis CI will do the rest.
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
- ## How to re-tag if a publish fails
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
- Delete broken tag:
17
+ ### Release.sh
17
18
 
18
- $ git tag -d "X.Y.Z" && git push origin :refs/tags/X.Y.Z
19
+ This script is not intended to be run locally. Note that it modifies your git
20
+ settings.
19
21
 
20
- Now you can re-tag and push as above.
22
+ The script will:
21
23
 
22
- ## Publishing manually
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
- Log in to npm as pact-foundation.
33
+ Should you need to modify the script locally, you will find it uses some
34
+ dependencies in `scripts/ci/lib`.
25
35
 
26
- Run the following commands:
36
+ ## Kicking off a release
27
37
 
28
- $ npm run dist
29
- $ npm run coverage
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
- This should have published the latest version, check to see that at npmjs.com/package/pact.
36
- We now need to create a GitHub release, upload zipped distribution (pactjs.tar.gz) to [GitHub Releases](https://github.com/pact-foundation/pact-js/releases).
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
- ## Updating NPM key
45
+ Then wait for github to do its magic. It will release the current head of master.
39
46
 
40
- Log in to pact-foundation npm account in a browser and revoke the old key in the Tokens section.
41
- Delete the env.global.secure key from travis.yml
42
- Log in to npm via command line using the pact-foundation account.
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
- $ gem install travis
46
- $ travis encrypt NPM_KEY=${NPM_KEY} --add env.global
51
+ ## If the release fails
47
52
 
48
- ## v3.0.0
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
- The native binaries required for post-install are trigerred [Github Actions](https://github.com/pact-foundation/pact-js/actions) on successful travis builds.
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
- Occasionally, you may need to generate these binaries manually. You can do so by running the command as follows (be careful to substitute branches/tagse etc.):
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
- For linux64 (update version of node you need to release from in the docker image name). Please run the steps by hand:
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
- docker run --rm -it -v $(pwd):/app node:latest bash
68
- apt-get update -y
69
- curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
70
- curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \
71
- sh -s -- -y
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-beta.9",
3
+ "version": "10.0.0",
4
4
  "description": "Pact for all things Javascript",
5
- "main": "./pact.js",
6
- "types": "./pact.d.ts",
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 dist-web coverage .nyc_output logs pacts jscpd.json",
13
- "clean:native": "rm -rf native/target",
14
- "coverage": "nyc report --reporter=text-lcov | coveralls",
15
- "deploy:package": "tar -czf pactjs.tar.gz config dist src package.json README.md LICENSE",
16
- "deploy:prepare": "npm i --production && npm run deploy:package && ./scripts/create_npmrc_file.sh",
17
- "dist": "npm run compile && webpack --config ./config/webpack.web.config.js && cp package.json ./dist",
18
- "jscpd": "jscpd -p src -r json -o jscpd.json",
19
- "lint": "npm run lint:prettier:ts && npm run lint:prettier:js",
20
- "lint:fix": "prettier --parser typescript --write \"{src,test,examples}/**/*.ts\" && prettier --write \"{src,test,examples}/**/*.js\"",
21
- "lint:prettier:ts": "prettier --parser typescript --check \"{src,test,examples}/**/*.ts\"",
22
- "lint:prettier:js": "prettier --check \"{src,test,examples}/**/*.js\"",
23
- "postdist": "npm t",
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": ">=6"
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": "http://docs.pact.io/documentation/javascript.html",
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-node": "^10.9.0",
97
+ "@pact-foundation/pact-core": "^13.6.2",
86
98
  "@types/bluebird": "^3.5.20",
87
- "@types/bunyan": "^1.8.3",
88
- "@types/express": "^4.11.1",
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.18.2",
92
- "bunyan": "^1.8.12",
93
- "bunyan-prettystream": "^0.1.3",
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
- "http-proxy-middleware": "^0.19.0",
102
- "lodash": "^4.17.14",
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
- "node-pre-gyp": "^0.13.0",
109
- "node-pre-gyp-github": "^1.4.3",
115
+ "pino-pretty": "^6.0.0",
110
116
  "pkginfo": "^0.4.1",
111
- "popsicle": "^9.2.0",
112
- "ramda": "^0.26.1"
117
+ "ramda": "^0.27.2",
118
+ "randexp": "^0.5.3"
113
119
  },
114
120
  "devDependencies": {
115
- "@babel/cli": "~7.6.0",
116
- "@babel/core": "^7.6.4",
117
- "@babel/preset-env": "^7.6.3",
118
- "@types/chai": "^4.0.3",
119
- "@types/chai-as-promised": "0.0.31",
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/form-data": "^2.2.1",
122
- "@types/lodash": "^4.14.73",
123
- "@types/lodash.isnil": "^4.0.3",
124
- "@types/mocha": "^2.2.41",
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/q": "^1.5.2",
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
- "awesome-typescript-loader": "^5.2.0",
134
- "babel-eslint": "~10.0.3",
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
- "coveralls": "^3.0.2",
146
+ "copyfiles": "^2.4.1",
139
147
  "enhanced-resolve": "^3.4.1",
140
- "eslint": "^5.6.1",
141
- "eslint-config-prettier": "^5.0.0",
142
- "eslint-plugin-prettier": "^3.1.0",
143
- "imports-loader": "~0.7.1",
144
- "istanbul": "~0.4.5",
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": "^5.1.1",
158
+ "mocha": "^9.1.1",
151
159
  "mocha-lcov-reporter": "^1.3.0",
152
- "neon-cli": "^0.3.3",
160
+ "mockery": "^2.1.0",
161
+ "neon-cli": "^0.9.1",
153
162
  "nock": "^9.1.6",
154
- "nyc": "^15.0.0-beta.0",
155
- "prettier": "^1.18.2",
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": "^7.1.0",
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
- "tslint": "^5.11.0",
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,5 @@
1
+ export declare type AnyJson = boolean | number | string | null | JsonArray | JsonMap;
2
+ export interface JsonMap {
3
+ [key: string]: AnyJson;
4
+ }
5
+ export declare type JsonArray = Array<AnyJson>;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=jsonTypes.js.map
@@ -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