Pact-js: Proposal: Overhaul the Ruby library wrapping

Created on 3 Sep 2017  路  6Comments  路  Source: pact-foundation/pact-js

Currently, to make an update to core behaviour in the Pact JS library, we depend on the following upstream NPM dependencies to be updated before they are made available to pact-js:

These libraries in one way or another wrap the underlying Ruby libraries that provide core Pact functionality.

These capabilities have been amalgamated into a single Ruby package: https://github.com/pact-foundation/pact-ruby-standalone/ for convenience of library authors.

Pact Python and Pact Go take the simpler approach of embedding this directly in the main repository and do away with extra dependencies.

Pact Go has the advantage of distributing as a releasable binary package, and thus can create OS specific packages at release time.

Python pulls in the correct OS at install time.

Pros and Cons of each approach

Advantages of separate repositories:

  • Modular, single-concerns, simplifies understanding of main code base
  • Re-usability: can create other libraries

Disadvantages

  • Maintenance overhead - it sounds trivial, but a minor update to a Ruby library requires a bunch of tiny updates to all of these libraries and has to be orchestrated in sequence, waiting for Travis builds to complete etc.
  • The use of optional dependencies in the upstream modules breaks the ability to use package-lock.json properly, as the optional dependency will lock in the incorrect OS. See https://github.com/pact-foundation/pact-node/issues/42 for background
  • Barrier to entry for new contributors - having to wade through the 'dependency graph of hell', as it has been referred to

Options

  1. Convert the two upstream repositories (pact-provider-verifier-npm, pact-mock-service-npm) into a single standalone wrapper, which uses preinstall to dynamically install the correct ruby standalone and postinstall to validate the installation
  2. Do away with pact-provider-verifier-npm and pact-mock-service-npm and bring into pact-node
  3. Do aware with pact-provider-verifier-npm, pact-mock-service-npm and pact-node and move _everything_ into pact-js
help wanted

Most helpful comment

I'm all for going as flat as possible. Whichever model allows us to push out updates the most easily, I'm for.

All 6 comments

I'm all for going as flat as possible. Whichever model allows us to push out updates the most easily, I'm for.

As a starting point, I've just created a new repo to flatten the two npm repositories into one: https://github.com/pact-foundation/pact-standalone-npm.

As part of bringing this into pact-node, we'll transition over to using the service command (over start) which should start to resolve a number of Windows issues.

Stay tuned.

@mefellows you can merge the mock service and verifier together, potentially from the ruby side to make it easier, but you can't merge pact-node and the pact-x-npm repos. The latter creates and deploys separate OS/Architecture specific binaries, while pact-node just downloads the one that meets the user's criteria.

Personally, I'd prefer to spend that time to actually get the rust implementation ready and just use that instead.

How's your Rust @mboudreau ;-)

OK, see https://github.com/pact-foundation/pact-standalone-npm and https://github.com/pact-foundation/pact-node/pull/45. Things are moving.

Once this is done, I can pick back up some of the other key issues, namely #84, #81 and moving all commands to use 'service' to fix the windows forking issue.

Closing - the upgrade to pact-node 5.x.x (not too far away) will address this.

See https://github.com/pact-foundation/pact-js/tree/feat/pact-node-5xx for WIP branch.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alshdavid picture alshdavid  路  3Comments

kneczaj picture kneczaj  路  5Comments

bethesque picture bethesque  路  9Comments

AdrienDevillers picture AdrienDevillers  路  4Comments

christopher-francisco picture christopher-francisco  路  6Comments