How can one effectively tackle A, B, and C simultaneously, considering that A relies on B and B relies on C?

I am contemplating the most effective workflow for working on projects A, B, and C simultaneously, where project A relies on project B, which in turn relies on project C.

Currently, I have all three projects stored in one repository, which helped speed up the initial development process. This is how my working directory is structured:

/A/
/A/B
/A/B/C

Project A is the main development driver, but projects B and C are also evolving in parallel.

However, I would like to be able to release projects B and C individually as they are valuable on their own.

My dilemma lies in finding a way to do this without compromising the speed of my development process. While npm is useful for distributing and managing dependencies, constantly moving versions across the internet during development just to update files in different folders on my machine is not ideal :)

Manually copying files over is also not an efficient solution. The thought of having to switch directories to work on project B and then copy it back to /A/B is daunting and error-prone.

That's why git submodule appears to be the solution - it allows me to maintain my directory layout as is. When making changes to files in project B, I can test them directly in project A without the need for manual copying. Once ready, I can commit and push from all three folders, automatically syncing everything to three different repositories. It sounds perfect, yet many people dislike git submodule for various reasons.

This issue is similar when working on grunt plugins. With each plugin in its own repository, I find myself continuously copying it over to one of the projects using it for development purposes. By the end of the day, I copy it back to the grunt plugin working directory, make commits, and push them. Although manageable for a few plugins, it becomes cumbersome for the current project I am focusing on.

I am left wondering, what is the solution to streamline this process?

Answer №1

It's important to note that Git submodules are linked to a specific version of the external repository, meaning a particular commit.

If you need to update all Git submodules to the most recent version, you will need to execute a command like this: run a command:

git submodule foreach git pull origin master

In some cases, using npm instead of Git submodules may be more suitable. By listing your dependencies in the package.json file and running npm install at the root of the repository, you can retrieve them easily. If a dependency gets updated and a new version is released, simply run npm update again to match the version requirements specified in the package.json file. You can also use npm to specify a certain commit, similar to how Git submodules function:

{
  "devDependencies": {
    "dependency-a": "git://github.com/the-user-name/the-project-name.git#b3c24169432a924d05020c85f852d4a1736e66d4"
  }
}

Additionally, if you wish to utilize the latest version of a dependency, such as the master branch of a specific Git repository, you can do so with the following configuration:

{
  "devDependencies": {
    "dependency-a": "git://github.com/the-user-name/the-project-name.git#master"
  }
}

Answer №2

After experimenting with various workflows, I have come to the conclusion that git submodules are not the ideal solution for me. My primary concern is that they link projects together at a source code management level without clear visibility into how this linkage impacts the revision history, especially in scenarios where the head is detached. Instead, I prefer using npm for dependency management by leveraging a combination of `npm link` and git URLs. When I need to test something locally, `npm link` proves to be very useful. On the other hand, git URLs work well for resolving dependencies during pull requests. Ultimately, I aim to have a published module with a version number that corresponds to a git tag for easy reference and issue tracking. To achieve this in a single step, I rely on `npm version`. This approach allows for projects to interdepend at different levels of cohesion throughout my development process.

Answer №3

Is git subtree the solution in this scenario? An informative article discussing the advantages and disadvantages of using git subtree compared to git submodules can be found here: Alternatives To Git Submodule: Git Subtree.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Encountered a 'Topology is closed' error while using EJS

After creating my profile.ejs page, I encountered an error upon reloading the page. Can someone help me understand what's causing this issue? Below is all the code I've used. My setup includes Node.js and Express as the server technologies. I cam ...

What exactly is the function of the `node_modules` directory in the .pnpm environment?

Contemplating a shift from using npm to adopting pnpm. Prior to starting the migration process, I delved into the documentation on pnpm's motivation. The setup involves hard links to packages that point to .pnpm store(Centralized) in .pnpm, while wi ...

"Error: Unable to access the property '$emit' of an undefined value" - VueJS

I'm currently working on implementing a basic authentication system in vuejs. I have a set of objects containing valid usernames and passwords. I am looping through this list to validate the entered username and password. If there is a match, I trigge ...

Node.js applications on Openshift frequently encounter 503 errors

I am currently in the process of setting up my initial Node.js + express web application utilizing Openshift's complimentary service. After installing node + npm and Openshift tools on my computer, I attempted to run my application. It functions perf ...

Difficulty navigating through nested arrays

One instance involves the use of the fetch API to retrieve data from the NY Times API. Within the response, there is an object titled "Multimedia" containing images. I've devised a template literal to extract the required information but for some reas ...

What is the best way to execute an inline function two times in a row

I'm currently utilizing Gametime.js to create a real-time world chat feature. All messages are kept in a database for storage. Interestingly, PubNub, which is used by Gametime.js, seems to require messages to be sent twice for them to actually go th ...

What is the best method to choose a random color for the background when a button is pressed?

Does anyone know how to create a button that changes the background color of a webpage each time it is clicked? I've been having trouble with the javascript function in my code. I've tried multiple solutions but nothing seems to work. Could someo ...

The ng-click functionality is not functioning as expected within the directive

Take a look at this snippet of my HTML: <section ng-controller="GalleryController as gallery"> <nav footer-directive></nav> </section> This is the GalleryController I'm using: angular .module('myapp') ...

Initial orientation in the first-person control of Three.js

Is there a way to define a specific starting orientation for the FirstPersonControls in Three.js? I need the starting orientation to vary based on the view, but currently it always begins with vector3(0,0,0) as the target. How can I change this to start ...

Freshening up the data source in a Bootstrap Typeahead using JavaScript

I'm trying to create a dropdown menu that displays options from an array stored in a file called companyinfo.js, which I retrieve using ajax. The dropDownList() function is called when the page loads. function dropDownList (evt) { console.log("dr ...

Tips for avoiding duplicate elements in ASP.NET during postback

My issue is that I have a div with the ID "mydiv" and runat=server. <div ID="mydiv" runat="server"></div> I move mydiv to a Container using jQuery. $("#mydiv").appendTo('#Container'); After a PostBack, my div gets duplicated and I ...

What could be causing the issue with Hindi text not displaying properly on Safari?

I'm having trouble with displaying Hindi text on my website. I tried pasting the text in a new file and it worked, so why is it not loading correctly in this case? The Hindi script is within the second span with the class word w2. "use strict"; le ...

What is the solution to prevent expressJS routes from displaying "cannot get /somepath" in the browser?

I've been working on a project using React, and I'm trying to create a unique route in the front end without having to create a separate HTML file for each new route. I want everything to be handled within a single page to maintain the current st ...

How to handle JSON parsing in a sails.js controller with node.js

Within my MapController, I have created a function to parse remote JSON files and populate an array called "parsewebservice" through an if-else structure. While everything seems to be working fine, the issue arises when trying to log the values of parseweb ...

Using the Greasemonkey browser extension, one can employ the waitForKeyElements utility to trigger a function once a designated element becomes visible on the webpage

(In connection to the question I posted on Stack Overflow). I have been developing a userscript for metal-archives.com, which can be found here. When you navigate to a band page (like this example), you will see the DISCOGRAPHY section and its sub-tabs ...

Include a text input field within the multipleTextBox component

How do I select a file and turn it into an option? For example, if there is a file on a server or my desktop, What is the best way to create a function that can handle this? Is AJAX the solution? <input type="text" name="name" value="text " ...

Is it possible for me to create a distinct component that can display numerous input fields at once?

Introducing the inputArea component, which collects data from input fields and sends it to the server: export default class InputArea extends React.Component { constructor(props){ super(props); this.state = { draw_number: '', ...

Why should "package-lock.json" from npm be included in version control?

Is it worthwhile to include npm's package-lock.json in version control? From my own experience, having this file controlled by source has led to more confusion and issues than benefits. Including package-lock.json in version control becomes a signifi ...

Meteor throws a "ReferenceError: module is not defined" error message following the installation of a package

I have created a meteor package that includes the ZiggeoSDK API to seamlessly integrate Ziggeo into my meteor app. However, upon installing this package, I encountered the following error: ReferenceError: module is not defined The Ziggeo Node Server SD ...

Is there a way to compel the browser or JavaScript to delete/disregard a cached file?

I've encountered an issue with my Javascript program that extracts data from a text file and displays it in a table. The problem arises when I update the text file - the changes don't reflect on the table because the browser is caching the file. ...