Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Proposal/RFC] Adding support for local git repositories #86

Open
MoralCode opened this issue Jan 31, 2021 · 4 comments
Open

[Feature Proposal/RFC] Adding support for local git repositories #86

MoralCode opened this issue Jan 31, 2021 · 4 comments

Comments

@MoralCode
Copy link

Mavo seems nearly perfect for my usecase, however for one website that I'm planning to use Mavo with, I'd rather not have a public github repository (or make the client sign up to github).

I wanted to make this feature proposal as a sort of Request-For-Comment to see if creating a new storage backend based on the github one, but intended for local git repositories (i.e. where the git repository is stored on the same server that is hosting the site).

I imagine this would act exactly like the github integration but would make the commits to either a repository in the current directory, or a more custom setup with a bare repository in another folder (using git worktree) so that the .git folder is not being served by the web server. This would allow a local git username and email address to be set up for use as the identity for making commits so that git is completely abstracted away from the end user (such as when a developer is setting this up for a client).

To replace the github auth (and thus continue to control who is able to make changes to the repository) i was thinking of either setting up some local login database that could run on the webserver to provide a login functionality, or possibly using some kind of oauth (like sign in with google) so the user is able to make edits if they successfully complete a "sign in with google" exchange and authenticate as an account that is on a predefined list of allowed editors (and possibly mapped to git commit identities).

While I should be able to make this happen myself by reading the awesome docs on plugins and storage backends, I'm pretty much brand new to Mavo and wanted to see if the community had any feedback on how to do this (or if anything can be added to help it benefit the community even further). From my research so far, it seems like, most critically, this would depend on the ability of Mavo to run git comands (or other system commands) on the web server. Does Mavo's achitecture have a server side/backend component, or is it all frontend node?

@karger
Copy link
Collaborator

karger commented Jan 31, 2021 via email

@LeaVerou
Copy link
Member

LeaVerou commented Jan 31, 2021

Let's take a step back for a moment. You mention that you don't want your client to have to sign up to Github, and also that you want the data to be private. Then you suggest Mavo writing to a local git repository as a solution to these issues. Are there other reasons you want a local git repo as a backend? Because for the two issues you mentioned, there are many other solutions.

First, the data doesn't have to reside in a public repo, a private repo works fine. In that case however, one would need to be logged in to view the data. A workaround for that would be to use mv-storage that points to your Github repo and mv-source that points to a public URL to your data (even the one provided by Github Pages if there's nothing else).

To avoid your client signing up to Github, you could use any of the other backends: Dropbox, Google Drive, Firebase etc. However, if you were going to set up a local git repo and do all the things you describe to log your client in, you may as well register for them on Github and log in for them.

Does Mavo's architecture have a server side/backend component, or is it all frontend node?

It's 99.9% frontend code. There is a server component to authenticate with some of the APIs.

@MoralCode
Copy link
Author

here are some different methods I was thinking of for achieving this:

  • If mavo has a server-side component, find or create a node package or some other functionality that would essentially allow mavo to run git commands on the server (something like exec("git commit -Am "Update files") when the save button is clicked for example).
  • If Mavo doesn't have a backend, create a program that would expose some kind of API (definitely like the idea of using a standard one like github's REST or GraphQL API's, although a cursory check of GitHub's GitHub account doesn't seem to turn up any server-side implementations of either API). This API could then be used by Mavo (with a token provided by Oauth) to send git commit information that the program essentially proxies into a git command on the configured repo with the commit identity corresponding to the Oauth credentials used.
  • Find or create a node library that can be used to create the commit client side and send the git packed objects over HTTP to git-http-backend.
  • use GitLab's Commits API (source code, probably) as the standard (since it seems like GitHub's is not open source).

@MoralCode
Copy link
Author

MoralCode commented Feb 2, 2021

@LeaVerou Whoops. didnt see your message above when i posted my last one.

The web server is currently set up with staging and production versions of the site as different branches so I probably could find a way to use a storage backend like GitHub or Gitlab (Gitlab offers sign in with google .etc) and just have give each branch a different mv-storage value pointing to that branch. Although to avoid accidentally merging that value from staging to prod it might be preferable to be able to specify the branch/storage location in a .gitignore'd .mavo-storage config file.

It seems like GitLab support via a plugin be something would be helpful for this and other users as well.

Would these be featured that would be helpful (either as plugins or pull requests)?

While not the most practical solution, I did also find https://plugins.mavo.io/plugin/php that seems to follow a very similar architecture to my initial proposal and could likely be adapted to work with and commit to a local git repo or worktree for people with different requirements.

@LeaVerou LeaVerou transferred this issue from mavoweb/mavo Feb 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants