diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 0bccb1e7..5f80afaa 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,6 +1,6 @@ --- name: Bug report -about: Report a bug with pact-node +about: Report a bug with pact-js-core title: '' labels: bug assignees: '' diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index bde600c3..24d2d7f1 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -19,15 +19,15 @@ _This checklist is optional, but studies show that people who have followed it c Before making a feature request, I have: -- [ ] [Searched the issues to check that this feature hasn't been requested before](https://github.com/pact-foundation/pact-node/issues?q=is%3Aissue) +- [ ] [Searched the issues to check that this feature hasn't been requested before](https://github.com/pact-foundation/pact-js-core/issues?q=is%3Aissue) - [ ] Checked the documentation to see if it is possible to do what I want already ### Feature description -_Please describe what you would like Pact-node to do_ +_Please describe what you would like Pact-js-core to do_ ### Use case _What is the use case that motivates this feature request?_ -_Please describe *why* you would like Pact-node to have this feature._ +_Please describe *why* you would like Pact-js-core to have this feature._ diff --git a/.github/issue_template.md b/.github/issue_template.md index 86b6dd19..6b99c6a3 100644 --- a/.github/issue_template.md +++ b/.github/issue_template.md @@ -2,7 +2,7 @@ _Thank you for reporting an issue! We appreciate it very much. Issues are a big _NOTE: If your issue is a how-to question, it is probably better asked in the pact-foundation slack channel, https://slack.pact.io/ _ -_This is the template for issues that aren't feature requests or bug reports. If your issue is a feature request or bug report, please use the relevant template from https://github.com/pact-foundation/pact-node/issues/new/choose - these will cover off the most common questions we ask and speed up a fix_ +_This is the template for issues that aren't feature requests or bug reports. If your issue is a feature request or bug report, please use the relevant template from https://github.com/pact-foundation/pact-js-core/issues/new/choose - these will cover off the most common questions we ask and speed up a fix_ _If you're reading this thinking "Hmmm, it is bug report/feature request, but neither of those templates work for what I want to report", then please feel free to ignore the template in whatever way you think best suits your issue. We trust you, you're awesome_ diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index f7ec9a6c..961d6235 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -2,7 +2,7 @@ _Please read and then remove this section_ Thank you for making a pull request! -Pact-node is built and maintained by developers like you, and we appreciate contributions very much. You are awesome! +Pact-js-core is built and maintained by developers like you, and we appreciate contributions very much. You are awesome! Our changelog is automatically built from our commit history, using conventional changelog. This means we'd like to take care that: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9022982e..f7ad3303 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -13,8 +13,8 @@ Please provide the following information with your issue to enable us to respond ## I want to contribute code but don't know where to start -If you're not sure where to start, look for the [help wanted](https://github.com/pact-foundation/pact-node/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) -label in our issue tracker. If you have an idea that you think would be great, come and chat to us on [slack] in the `#pact-node` channel, or open a feature request issue. +If you're not sure where to start, look for the [help wanted](https://github.com/pact-foundation/pact-core/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) +label in our issue tracker. If you have an idea that you think would be great, come and chat to us on [slack] in the `#pact-js` channel, or open a feature request issue. ## I'm ready to contribute code @@ -26,7 +26,7 @@ Pact Node uses the [Conventional Changelog](https://github.com/bcoe/conventional commit message conventions to simplify automation process. Please ensure you follow the guidelines. You can take a look at the git history (`git log`) to get the gist of it. -If you have questions, feel free to reach out in `#pact-node` in our [slack +If you have questions, feel free to reach out in `#pact-js` in our [slack community](https://pact-foundation.slack.com/). #### Release notes diff --git a/README.md b/README.md index fd791919..b6c6d5eb 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,23 @@ -![Build and test](https://github.com/pact-foundation/pact-node/workflows/Build%20and%20test/badge.svg) -[![Known Vulnerabilities](https://snyk.io/test/github/pact-foundation/pact-node/badge.svg?targetFile=package.json)](https://snyk.io/test/github/pact-foundation/pact-node?targetFile=package.json) -[![npm](https://img.shields.io/npm/v/@pact-foundation/pact-node.svg)](https://www.npmjs.com/package/@pact-foundation/pact-node) -[![license](https://img.shields.io/github/license/pact-foundation/pact-node.svg)](https://github.com/pact-foundation/pact-node/blob/master/LICENSE) -[![dependencies](https://img.shields.io/david/pact-foundation/pact-node.svg)](https://www.npmjs.com/package/@pact-foundation/pact-node) +![Build and test](https://github.com/pact-foundation/pact-js-core/workflows/Build%20and%20test/badge.svg) +[![Known Vulnerabilities](https://snyk.io/test/github/pact-foundation/pact-js-core/badge.svg?targetFile=package.json)](https://snyk.io/test/github/pact-foundation/pact-js-core?targetFile=package.json) +[![npm](https://img.shields.io/npm/v/@pact-foundation/pact-js-core.svg)](https://www.npmjs.com/package/@pact-foundation/pact-core) +[![license](https://img.shields.io/github/license/pact-foundation/pact-js-core.svg)](https://github.com/pact-foundation/pact-js-core/blob/master/LICENSE) +[![dependencies](https://img.shields.io/david/pact-foundation/pact-js-core.svg)](https://www.npmjs.com/package/@pact-foundation/pact-core) [![slack](http://slack.pact.io/badge.svg)](http://slack.pact.io) -# Pact Node +# Pact-JS Core -An idiomatic Node wrapper for the [Pact](http://pact.io) [CLI Tools](https://github.com/pact-foundation/pact-ruby-standalone). +**This is the core of pact-js. Unless you are wanting to develop tools for the pact ecosystem, you almost certainly want to install [`@pact-foundation/pact`](https://github.com/pact-foundation/pact-js/) instead**. -***NOTE*: If you are new to Pact and are wanting to get started with contract testing, you almost certainly don't want to use this package. Head over to [Pact JS](https://github.com/pact-foundation/pact-js/) instead.** +A wrapper for the [Pact](http://pact.io) [CLI Tools](https://github.com/pact-foundation/pact-ruby-standalone). + +***If you are new to Pact and are wanting to get started with contract testing, you almost certainly don't want to use this package. Head over to [Pact JS](https://github.com/pact-foundation/pact-js/) instead.** -- [Pact Node](#pact-node) +- [Pact Core](#pact-js-core) - [Installation](#installation) - [Do Not Track](#do-not-track) - [Pact Download Location](#pact-download-location) @@ -47,7 +49,7 @@ An idiomatic Node wrapper for the [Pact](http://pact.io) [CLI Tools](https://git ## Installation -`npm install @pact-foundation/pact-node --save` +`npm install @pact-foundation/pact-core --save-dev` ### Do Not Track @@ -79,7 +81,7 @@ For those that are behind a corporate firewall or are seeing issues where our pa } ``` -It will accept both a local path or an http(s) url. It must point to the directory containing the binary needed as the binary name is appended to the end of the location. For the example given above, Pact will look for the binary at `/home/some-user/Downloads/pact-1.44.0-win32.zip` for a Windows system. However, by using this method, you must use the correct Pact version binary associated with this version of Pact-Node. For extra security measurements, checksum validation has been added to prevent tampering with the binaries. +It will accept both a local path or an http(s) url. It must point to the directory containing the binary needed as the binary name is appended to the end of the location. For the example given above, Pact will look for the binary at `/home/some-user/Downloads/pact-1.44.0-win32.zip` for a Windows system. However, by using this method, you must use the correct Pact version binary associated with this version of Pact-Core. For extra security measurements, checksum validation has been added to prevent tampering with the binaries. If your environment uses self-signed certificates from an internal Certificate Authority (CA), you can configure this using the standard options in an [npmrc](https://docs.npmjs.com/configuring-npm/npmrc.html) file as per below: @@ -95,7 +97,7 @@ You can also force Pact to skip the installation of the binary during `npm insta setting `PACT_SKIP_BINARY_INSTALL=true`. This feature is useful if you want to speed up builds that don't need Pact and don't want to modify your projects dependencies. -Note that pact-node will not be functional without the binary. +Note that pact-core will not be functional without the binary. ```bash PACT_SKIP_BINARY_INSTALL=true npm install @@ -121,7 +123,7 @@ TL;DR - you almost always want Pact JS. Simply require the library and call the create function to start the mock service ```js -var pact = require("@pact-foundation/pact-node"); +var pact = require("@pact-foundation/pact-core"); var server = pact.createServer({ port: 9999 }); server.start().then(function() { // Do your testing/development here @@ -131,7 +133,7 @@ server.start().then(function() { Or if you're using Typescript instead of plain old Javascript ```ts -import pact from "@pact-foundation/pact-node"; +import pact from "@pact-foundation/pact-core"; const server = pact.createServer({ port: 9999 }); server.start().then(() => { // Do your testing/development here @@ -151,7 +153,7 @@ To see the list commands possible with the CLI, simply ask for help `$# pact --h ### Set Log Level ```js -var pact = require("@pact-foundation/pact-node"); +var pact = require("@pact-foundation/pact-core"); pact.logLevel("debug"); ``` @@ -162,7 +164,7 @@ Mock servers are used by Pact to record interactions and create pact contracts. #### Create Mock Server ```js -var pact = require('@pact-foundation/pact-node'); +var pact = require('@pact-foundation/pact-core'); var server = pact.createServer({ ... }); @@ -193,7 +195,7 @@ var server = pact.createServer({ If you ever need to see which servers are currently created. ```js -var pact = require("@pact-foundation/pact-node"); +var pact = require("@pact-foundation/pact-core"); var servers = pact.listServers(); console.log(JSON.stringify(servers)); ``` @@ -203,7 +205,7 @@ console.log(JSON.stringify(servers)); Remove all servers once you're done with them in one fell swoop. ```js -var pact = require("@pact-foundation/pact-node"); +var pact = require("@pact-foundation/pact-core"); pact.removeAllServers(); ``` @@ -212,7 +214,7 @@ pact.removeAllServers(); Start the current server. ```js -var pact = require("@pact-foundation/pact-node"); +var pact = require("@pact-foundation/pact-core"); pact.createServer() .start() .then(function() { @@ -225,7 +227,7 @@ pact.createServer() Stop the current server. ```js -var pact = require("@pact-foundation/pact-node"); +var pact = require("@pact-foundation/pact-core"); pact.createServer() .stop() .then(function() { @@ -238,7 +240,7 @@ pact.createServer() Stop the current server and deletes it from the list. ```js -var pact = require("@pact-foundation/pact-node"); +var pact = require("@pact-foundation/pact-core"); pact.createServer() .delete() .then(function() { @@ -249,7 +251,7 @@ pact.createServer() #### Check if a Mock server is running ```js -var pact = require("@pact-foundation/pact-node"); +var pact = require("@pact-foundation/pact-core"); pact.createServer().running; ``` @@ -258,7 +260,7 @@ pact.createServer().running; There's 3 different events available, 'start', 'stop' and 'delete'. They can be listened to the same way as an [EventEmitter](https://nodejs.org/api/events.html). ```js -var pact = require("@pact-foundation/pact-node"); +var pact = require("@pact-foundation/pact-core"); var server = pact.createServer(); server.on("start", function() { console.log("started"); @@ -276,7 +278,7 @@ server.on("delete", function() { Read more about [Verify Pacts](https://github.com/realestate-com-au/pact/wiki/Verifying-pacts). ```js -var pact = require('@pact-foundation/pact-node'); +var pact = require('@pact-foundation/pact-core'); pact.verifyPacts({ ... @@ -313,7 +315,7 @@ pact.verifyPacts({ ### Pact Broker Publishing ```js -var pact = require('@pact-foundation/pact-node'); +var pact = require('@pact-foundation/pact-core'); var opts = { ... }; @@ -339,7 +341,7 @@ pact.publishPacts(opts).then(function () { ### Pact Broker Deployment Check ```js -var pact = require('@pact-foundation/pact-node'); +var pact = require('@pact-foundation/pact-core'); var opts = { ... }; @@ -386,7 +388,7 @@ The interface is comparable to the Mock Server API. #### Create Stub Server ```js -var pact = require('@pact-foundation/pact-node'); +var pact = require('@pact-foundation/pact-core'); var server = pact.createStub({ ... }); @@ -411,7 +413,7 @@ var server = pact.createStub({ #### Create Message Pacts ```js -var pact = require('@pact-foundation/pact-node'); +var pact = require('@pact-foundation/pact-core'); var message = pact.createMessage({ ... }); @@ -454,7 +456,7 @@ This means you may call them direct from scripts in your package json, for examp "scripts": { "pactPublish": "pact-broker publish ./pacts --consumer-app-version=$\(git describe\) --broker-base-url=$BROKER_BASE_URL --broker-username=$BROKER_USERNAME --broker-password=BROKER_PASSWORD"` } -These are available in circumstances where `pact-node` has not yet implemented a feature or access via JavaScript APIs is not desirable. To run the binaries is as simple as the following: +These are available in circumstances where `pact-core` has not yet implemented a feature or access via JavaScript APIs is not desirable. To run the binaries is as simple as the following: *Example can-i-deploy check*: ```sh @@ -482,7 +484,7 @@ The following are the binaries currently made available: ### Enable Long Paths -[Windows has a default path length limit of 260](https://docs.microsoft.com/en-us/windows/desktop/fileio/naming-a-file#maximum-path-length-limitation) causing issues with projects that are nested deep inside several directory and with how npm handles node_modules directory structures. To fix this issue, please enable Windows Long Paths in the registry by running `regedit.exe`, find the key `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabled` and change the value from `0` to `1`, then reboot your computer. Pact should now work as it should, if not, please [raise an issue on github](https://github.com/pact-foundation/pact-node/issues). +[Windows has a default path length limit of 260](https://docs.microsoft.com/en-us/windows/desktop/fileio/naming-a-file#maximum-path-length-limitation) causing issues with projects that are nested deep inside several directory and with how npm handles node_modules directory structures. To fix this issue, please enable Windows Long Paths in the registry by running `regedit.exe`, find the key `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabled` and change the value from `0` to `1`, then reboot your computer. Pact should now work as it should, if not, please [raise an issue on github](https://github.com/pact-foundation/pact-js-core/issues). ## Contributing diff --git a/RELEASING.md b/RELEASING.md index 319355ed..fc1bc5f0 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -36,7 +36,7 @@ dependencies in `scripts/ci/lib`. ## Kicking off a release You must be able to create a github access token with `repo` scope to the -pact-node repository. +pact-js-core repository. - Set an environment variable `GITHUB_ACCESS_TOKEN_FOR_PF_RELEASES` to this token. - Make sure master contains the code you want to release @@ -69,7 +69,7 @@ may need to rebase them on top of the tagged release commit and force push. ## Releasing Pact Node Manually -If any changes needs to be released, let it be dependencies or code, you must have access to push directly to master on the pact-node repo, then follow these steps: +If any changes needs to be released, let it be dependencies or code, you must have access to push directly to master on the pact-js-core repo, then follow these steps: - Run `npm ci --ignore-scripts` to confirm that the dependencies are appropriately configured. - Run `npm test` first to make sure all tests pass. This will also build and download the appropriate checksums. diff --git a/package.json b/package.json index ea4a4296..4bd4d7bc 100755 --- a/package.json +++ b/package.json @@ -1,9 +1,9 @@ { - "name": "@pact-foundation/pact-node", + "name": "@pact-foundation/pact-core", "version": "10.11.11", - "description": "A wrapper for the Ruby version of Pact to work within Node", + "description": "Core of @pact-foundation/pact. You almost certainly don't want to depend on this directly.", "main": "src/index.js", - "homepage": "https://github.com/pact-foundation/pact-node#readme", + "homepage": "https://github.com/pact-foundation/pact-js-core#readme", "types": "src/index.d.ts", "bin": { "pact": "bin/pact.js", @@ -27,7 +27,7 @@ }, "repository": { "type": "git", - "url": "git://github.com/pact-foundation/pact-node.git" + "url": "git://github.com/pact-foundation/pact-js-core.git" }, "keywords": [ "pact", @@ -44,7 +44,7 @@ ], "license": "MIT", "bugs": { - "url": "https://github.com/pact-foundation/pact-node/issues" + "url": "https://github.com/pact-foundation/pact-js-core/issues" }, "publishConfig": { "access": "public" diff --git a/script/ci/lib/publish.sh b/script/ci/lib/publish.sh index 3fd47c6f..dda58dd1 100755 --- a/script/ci/lib/publish.sh +++ b/script/ci/lib/publish.sh @@ -12,6 +12,6 @@ echo "--> Preparing npmrc file" echo "--> Releasing version ${VERSION}" echo "--> Releasing artifacts" -echo " Publishing pact-node@${VERSION}..." +echo " Publishing pact-core@${VERSION}..." npm publish --access public --tag latest echo " done!" diff --git a/src/logger.ts b/src/logger.ts index 02c06e84..d7ff6e39 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -12,7 +12,7 @@ const createLogger = (level: LogLevels = DEFAULT_LEVEL): Logger => pino({ level: level.toLowerCase(), prettyPrint: { - messageFormat: `pact-node@${pkg.version}: {msg}`, + messageFormat: `pact-core@${pkg.version}: {msg}`, translateTime: true, }, }); diff --git a/src/pact.ts b/src/pact.ts index 15178269..89bc34f8 100644 --- a/src/pact.ts +++ b/src/pact.ts @@ -32,7 +32,7 @@ export class Pact { } catch { logger.warn( 'WARNING: Windows Long Paths is not enabled and might cause Pact to crash if the path is too long. ' + - 'To fix this issue, please consult https://github.com/pact-foundation/pact-node#enable-long-paths`', + 'To fix this issue, please consult https://github.com/pact-foundation/pact-js-core#enable-long-paths`', ); } } diff --git a/src/service.ts b/src/service.ts index b1100864..026040d4 100644 --- a/src/service.ts +++ b/src/service.ts @@ -53,7 +53,7 @@ export abstract class AbstractService extends events.EventEmitter { // Set logger first if (options.logLevel) { setLogLevel(options.logLevel); - // Pact-node's logger supports fatal and trace, + // Pact-js-core's logger supports fatal and trace, // but the ruby binary doesn't. So we map those. if ((options.logLevel as string) === 'fatal') { options.logLevel = 'error'; @@ -327,7 +327,7 @@ export interface ServiceOptions { logLevel?: LogLevel; } -// This is the pact binary's log level, which is a subset of the log levels for pact-node +// This is the pact binary's log level, which is a subset of the log levels for pact-core export type LogLevel = 'debug' | 'info' | 'warn' | 'error'; export interface HTTPConfig { diff --git a/standalone/install.ts b/standalone/install.ts index 7ea207e8..fe6542dc 100644 --- a/standalone/install.ts +++ b/standalone/install.ts @@ -163,7 +163,7 @@ function downloadFileRetry( request({ url, headers: { - 'User-Agent': 'https://github.com/pact-foundation/pact-node', + 'User-Agent': 'https://github.com/pact-foundation/pact-js-core', }, strictSSL: config.read()['strict-ssl'], agentOptions: { @@ -235,7 +235,7 @@ function download(data: Data): Promise { t: 'screenview', // Screenview hit type. an: 'pact-install', // App name. av: require('../package.json').version, // App version. - aid: 'pact-node', // App Id. + aid: 'pact-node', // App Id - pact-node for historical reasons aiid: `standalone-${PACT_STANDALONE_VERSION}`, // App Installer Id. cd: `download-node-${data.platform}-${isCI ? 'ci' : 'user'}`, aip: true, // Anonymise IP address