Project JSON Flow - Separate File per Flow/Tab?

Is there a way to configure Node-RED to create separate flow.json files - one for each "flow" (aka tab) within the set of flows for a given Node-RED Git enabled project? The reason being is that as an overall flow gets large it is convenient to be able to move a set of nodes to a specific flow/tab within the overall Node-RED project (as is currently supported). However, when this is done Node-RED still saves all of flows configuration to a single flow.json file (instead a separate .json file for each flow). From the Git version control perspective, effectively the entire program's "code" lives in a single file - which can get very large. Several benefits would be provided, from a Git perspective, if each distinct flow/tab was saved into its own file (e.g. smaller individual flow files, version history per flow, easier multi-user team development - e.g. each team member responsible for a specific flow file, etc.)

If this can't be done today could this feature be considered? For example, allow the settings.js file to optionally have Node-RED save each flow/tab to a separate file - with perhaps the master flow.json file pointing to each of the individual flow files. Thanks.

PS - I used to develop with Microsoft LightSwitch (now discontinued btw) which was similar to Node-RED in that it was RAD tool with a visual dev interface that would automatically generate program "code" - in their case it was XML. With the first version of LightSwitch the application would write all the "code" to a single file - but eventually based on feedback (specifically regarding the size of the "code" file and to also facilitate multi-user project development) Microsoft enhanced LightSwitch so that each distinct screen would be written to its own file.

4 Likes

A very interesting demand. I second that. :+1:

so Microsoft lightswitch started with a single file - then moved to multiple files - then the project folded.... not sure that is a path we want to follow :slight_smile:

3 Likes

@dceejay, it's easy: just do the "multiple files" feature while avoiding the "project folding" feature ... :stuck_out_tongue_winking_eye:

1 Like

Hi,

Yes this has been discussed lots of times. There is an item on the backlog for looking at how to split up the flow file.

4 Likes

We had an internal plugin in the past that did exactly that. It does help git workflows to some extent. I also wrote a public node that converts flows to YAML, the nice thing is it allows multiline function nodes so diffs are easier. Having both possibilities would be the best, we also work with very large projects (20 tabs, 30-40 subflows) and git work with more than 2 persons is almost impossible, we have to take turns which is less than ideal. The projects feature could help but I'm not convinced it would be efficient for very large projects.

1 Like

Had a discussion on Twitter about this today (https://twitter.com/tiefpunkt/status/1238969993146105858). Has anyone gotten any further on this?
My goal would be to be able to put each Flow/Tab into a different git repo and manage them separately, but I guess the first step would be to split the flow json. I was just looking at the API of the storage backend, and I suppose it should be doable, so I'll give that a try. My JS skills are rather limited though, so if anyone could give me a hand at some point, that would be greatly appreciated :wink:

I put something together, just a very quick thing: https://github.com/tiefpunkt/node-red-splitstorage

The idea was to take the content of each tab and put it into a separate file, and then have a "main" file with the tabs and all the config nodes that aren't tied to a tab. If the normal flows file is called "flows.json", then the tab specific files will be called "flows_<tab.id>.json".

Is that something we could start out with?

Hello @adenysen , I also had the same thing in mind because it's easier to maintain if you work on a big project, especially if you need to merge changes of nodes, which is much harder to do with a gigantic master flow JSON file.
Came up with the following module: node-red-contrib-flow-manager
See if it works for you.

6 Likes

Is the item for multiple flow files per tab still on the backlog?
Can we leverage on the work done by @AlonAmiraabluedragon ?

Hello @knolleary @dceejay , I am just curious to know that do we expect this feature to be released in near future. I am loving the 2.0 major release. Kudos to the complete team involved in making it happen. I love the debugger and eslint options now.

I am very much keen to understand

  1. If we can achieve maintaining separate flow files for every tab and manage them with git directly from editor
  2. Having Multiple Tenant Node-RED system

I know you guys are already dealing with a lot of complex scenarios, so just feel free to let me know even if these items are not yet on the priority.

Any update on this?

Have you seen this similar conversation ?