Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publishing contracts of dependencies #17

Open
lukaszfiszer opened this issue Apr 19, 2021 · 0 comments
Open

Publishing contracts of dependencies #17

lukaszfiszer opened this issue Apr 19, 2021 · 0 comments

Comments

@lukaszfiszer
Copy link
Collaborator

lukaszfiszer commented Apr 19, 2021

Problem: if package B is a dependency of application A, and package B makes a request to a external API service, then we want this interaction to be included in contracts of application A.

Solution proposal:

package B declares contracts for its interactions:

  1. pact file is generated during build process, without consumer field
  2. reference to this pact files is defined via new pacts field in package.json
  3. generated pact file in included in the tarball published to the npm registry (for example using files property)

Example:

// package.json
{
  "name": "package-b",
  "pacts": ["dist/user-settings-pacts.json"],
  "files": ["dist"]
}

application A declares "package B" at its dependency:

// package.json
{
  "name": "application-a",
  "dependencies": {
    "package-b": "1.0.0"
  }
}

judge-d-js command when executed in application A root directory with new --include-dependencies-pacts flag
1. look at application A dependencies list from package.json
2. read each dependency package.json files and check if it contains pacts field
3. if it does, then read those pacts, set consumer field to the one passed as serviceName, a publish with the rest of the contracts

judge-d publish --serviceName application-a --serviceVersion 2.0.0 --include-dependencies-pacts  --pactsDir some/path --url https://example.com

Potential drawback

  • Application A will always publish contracts for all interactions implemented in package B, even if only a subset of functionality and interactions of package B is imported in the application
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant