git-applet
A bare-bones applet that handles basic Git commands on common Git-hosting platforms.
Documentation
Installation
Install by running:
npm install -g git-applet
or:
npm install -g https://github.com/NotTimTam/git-applet.git
Importing into your project
const GA = require("git-applet");
const gitHandler = new GA(
GA.gitPlatforms.github,
"my_example_token",
"NotTimTam",
"my-repo"
);
commitFileAndPush
Create or edit a file with a specific path.
gitHandler.commitFileAndPush(
"README.md",
"Hello, world!",
true,
"Added README.md."
);
doesFileExist
Check if a file exists in a directory.
gitHandler.doesFileExist(
"README.md"
);
getFileContents
Get the contents of a file in the repository.
gitHandler.getFileContents(
"README.md"
);
deleteFile
Delete an existing file.
gitHandler.deleteFile(
"README.md",
"Deleted README.md."
);
renameFile
Rename and/or move a file to a new directory.
gitHandler.renameFile(
"README.md",
"old/docs/README.md",
"Moved the old README."
);
getFileTree
Get a JSON object listing all the files and directories in the repository.
gitHandler.getFileTree();
apiRequest
Send a custom API request to the Git api.
gitHandler.apiRequest(
`${gitHandler.repositoryURL}/contents/README.md`,
"POST",
myData
);