DEV Community

Joseph Thomas
Joseph Thomas

Posted on

How to keep functionality in sync between codebases?

I'm building up a new project that will consist of a central API, which a number of different sub-projects will link into.

For simplicity's sake, let's say that part of the functionality of the whole platform is to get an image's metadata. This might happen in the core API, or on either the server or front-end of one of the sub-projects.

All of this will be written in Javascript, and functions like this will be pure and contained in their own modules. I'd like to have a single place where I can create and edit these modules, so that in any instance above, I can do something like:

import getImageMetaData from 'getImageMetadata'; // it's within node_modules

const resource = 'http://example.com/image.jpg'
const metaData = getImageMetaData(resource);

...
Enter fullscreen mode Exit fullscreen mode

Is the simplest way simply giving this module its own github repo, then including it in package.json on all of the different sides of the service, and constantly run (using hooks or whatever) npm install upgrade my-package?

Any smart ways to keep this all in sync? Preferably as automated as possible ~ there might be up to a dozen of the front-end sub-projects, and I want to be sure that I can fix all of them at once.

Top comments (2)

Collapse
 
ben profile image
Ben Halpern

So the issue is that you need all the consuming projects to be up-to-date with the latest version of each module? Are you going to be the one who will be re-running npm install upgrade my-package or is it other people?

Collapse
 
goodidea profile image
Joseph Thomas

Good question - right now, I'm the sole developer, but before long I may have one or two people on support staff. Ideally, this is something that will be automated, and I imagine that I could run an update with a git hook.

I also don't need this to happen through npm --- it's just what I'm familiar with. So far all of my work has been fairly contained in single instances - I'm new to more advanced/distributed setups and how to keep everything in sync.