Diff/merge tool for function nodes code

Hello,
I often have to compare different function nodes (within the same tab or different tabs) in order to find their differences out, and transfer some of the differences from one to the other.
Actually the easiest way to do this is to copy/paste their code in an external diff tool, find the differences, manually merge them by copying pieces to a final version, and finally paste the result back into the flow.
I think that an integrated tool to do so would help a lot and save much time.
I'm thinking about a classic diff/merge UI, with side-by-side contents, visually highlighted differences (added lines in green, removed lines in red, changed lines in blue or another color), and commands to transfer changes right-to-left or left-to-right.

Thanks for your attention!
Best regards,
Alberto Schena

Heh,

Sounds like an interesting problem a lot of the capability is already there. You could piece a lot of the bits together yourself,

The Admin API has the ability to extract details from a node including a function node. you could extract the code form the node, save it to a file, do the same with another node and save to a file.

Open the files in Visual studio code and do a compare and modify. Save the new file to a file name, load the file back into node red with another flow and update the function node.

I would experiment getting the bits to work. You will be surpised at how far you can get with the existing, stuff

Will be interested to see how you go

Visual studio code has a very good file compare capability. Using the function node to extract the the relevant

Hi.

Once we have access to monaco (the same code editor used by VSCode) in the editor, it will be fairly trivial to achieve an inline diff. Obviously implementation and effort vs benefit would need to be assessed.

NOTE: I'm not sure if ACE has this capability

Example of inline diff in monaco

The current state of monaco for node-red is that it is generally excepted by Nick as a possible V2 feature (obviously many details still to be ratified). The main thread is here if you are interested.

The monaco branch It is currently up to date with current dev branch (as of yesterday anyhow - things move fast & I do have a day job)

3 Likes

I have just read the thread on Monaco - looks very cool agree that will go a long way to solving the problem

Hey @aschena while developing monaco for node-red I decided to have a play.

Turns out to be quite easy to integrate diff functionality...

It is really basic and only a demo at this point but could some day end up in v2.x.x :slight_smile:

3 Likes

You tease Steve! :rofl:

2 Likes

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.