When developing Node.js projects, if two projects are related, such as the main system and the plugin, the main system and the sub-system, the main system and the dependent library, etc., many mysterious problems that appear in the middle are because the dependency version is not aligned.
If the dependency items of the two projects are consistent, only the version difference, then just copy and synchronize directly. But in fact, only some of the dependency items are consistent, and there are many unique dependency items in each project //(ㄒoㄒ)/~~
When dealing with this problem, I can only manually compare one by one, which is time-consuming and inefficient. At this time, if I can quickly compare the dependency version differences of the two projects or systems, I can quickly find the problem and solve it in time.
So I want to develop a tool that can help me more conveniently compare the dependency version differences of the two Node.js package.json files, find the new or deleted dependency items. Of course, I have added a lot of features that don't seem to be useful. . . just like this
If you also encountered the same problem, I hope this tool can help you. ^_^
The implementation principle of this tool is actually very simple, just extract the dependency part of the two package.json files, compare the differences, and find the difference items.
Originally, it could only extract the dependency part for comparison and display the results directly in a table. But in order to make it easier for users to view, I added line numbers, status bar, highlighting and other functions.
This brings a new problem, the first problem is that because the dependencies of both sides have their own differences, in order to make the user see the differences clearly and clearly, it is necessary to add placeholder lines to keep the line numbers on both sides consistent.
The second problem is the problem of the position of the next or previous difference when moving from one difference to the next. Because the placeholder line is virtual, it is necessary to calculate the corresponding real line number according to the difference type to ensure that the left and right are synchronized positioning
So I developed a slightly more complex text comparison panel to solve this problem, mainly managing the mapping relationship between the real line and the virtual line, the mapping of the difference line, the synchronization of the scroll, etc.
In short, my perfectionism led to the increase of the complexity of the tool, departing from the original intention of solving the problem(~ ̄(OO) ̄)ブ
A: No. All JSON formatting is done locally in your browser and will not be uploaded to any server.
A: Because the actual difference has been found, it needs to be arranged in a certain order, such as arranging the difference position order according to the left as the main. This requirement is relatively complicated, so it is temporarily not done
Node.js: Node.js is a JavaScript runtime environment that allows you to run JavaScript code on the server side
pnpm's workspace mode: pnpm's workspace mode is a mode of pnpm, which allows you to manage multiple sub-projects in the same project, each sub-project has its own package.json file, but they share the same node_modules directory, and the node_modules directory of each sub-project is isolated but linked to the node_modules directory of the root directory.
monorepo: monorepo is a project management method that allows multiple projects to share the same code warehouse, each project has its own package.json file but does not conflict
Explore more useful tools to improve your productivity