如何在纯Javascript中实现Git以创建GUI? [英] How to implement Git in pure Javascript to create a GUI?

查看:100
本文介绍了如何在纯Javascript中实现Git以创建GUI?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在搜索了很多东西之后,没有找到findind的任何信息,我在这里问你是否有一种方法可以在纯Javascript Web应用程序中实现Git. 我已经了解Git.js,但它仅实现了一些基本的功能,我还想构建自己的库以深入了解Git.

我不需要的是可以帮助我的API或库.

我正在寻找的东西是这样的:

var command = {{git commit -m "Hello world"}} // Also pure git implementation
gitExecute(command);

我仍然是一名初级开发人员,也许这可能是不可能的...感谢您的答复:)

解决方案

您想要的内容可能很难在浏览器中完成(因为您需要访问文件系统才能运行git命令).您可能需要做的是创建一个NodeJS服务器,该服务器公开REST终结点,可以通过提供GUI的浏览器中的代码进行访问. NodeJS服务器代码可以根据需要运行命令并响应REST HTTP请求,然后您的代码就可以在浏览器中使用它们来显示/更新GUI.

此方法的缺点是,您需要在具有存储库的计算机上运行NodeJS服务器,并且如果存储库不在服务器本地,则该计算机将无法工作.

另一种选择是使用流行的GIT提供程序提供的REST API,例如GitHub . >

请考虑一下,您的用例可能非常适合电子应用.这样一来,您就可以使用Javascript构建桌面应用程序(具有访问文件系统的权限和执行命令的权限).

after searching quite a lot without findind nothing about it I'm here to ask you if there is a way to implement Git in a pure Javascript web application. I already know about Git.js but it implements just some basic things and I also wanted to build my own library to learn more in depth about Git.

What I'm not looking for is an API or a lib that could help me.

What I'm looking for is something like:

var command = {{git commit -m "Hello world"}} // Also pure git implementation
gitExecute(command);

I'm still a junior developer and maybe this could be impossible...thanks for the reply :)

解决方案

What you are asking for may be difficult to do in a browser (because you will need access to the file system to run git commands). What you may need to do is create a NodeJS server which exposes REST endpoints which can be accessed by code in the browser which provides the GUI. The NodeJS server code can run commands as needed and respond to the REST HTTP requests which can be then used by your code in the browser to show/update the GUI.

The disadvantage with this method is that you will need to run your NodeJS server on the computer which has the repository and will not work if the repo is not local to the server.

Another alternative is to use the REST APIs exposed by popular GIT providers like GitHub.

EDIT:

Come to think of it, your usecase may be a good fit for an Electron App. That will allow you to build a desktop app (with access to the filesystem and privileges to execute commands) using Javascript.

这篇关于如何在纯Javascript中实现Git以创建GUI?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆