1.1.1 • Published 11 months ago

git-applet v1.1.1

Weekly downloads
-
License
CC0
Repository
github
Last release
11 months ago

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, // The repository api path for your Git platform. Common ones are stored under GA.gitPlatforms.
	"my_example_token", // Your Git platform access token.
	"NotTimTam", // The owner of the repository.
	"my-repo" // The name of the repository.
);

commitFileAndPush

Create or edit a file with a specific path.

// ...

gitHandler.commitFileAndPush(
	"README.md", // The path to commit the file to. Including the file's name and file extension.
	"Hello, world!", // The content of the file.
	true, // Whether to overwrite an existing file or not.
	"Added README.md." // An optional commit message.
);

doesFileExist

Check if a file exists in a directory.

// ...

// Returns the SHA of the existing file, or false.
gitHandler.doesFileExist(
	"README.md" // The path to the file to check.
);

getFileContents

Get the contents of a file in the repository.

// ...

gitHandler.getFileContents(
	"README.md" // The path to the file.
);

deleteFile

Delete an existing file.

// ...

gitHandler.deleteFile(
	"README.md", // The path to the file.
	"Deleted README.md." // An optional commit message.
);

renameFile

Rename and/or move a file to a new directory.

// ...

gitHandler.renameFile(
	"README.md", // The existing file location.
	"old/docs/README.md", // The new file location/name.
	"Moved the old README." // An optional commit message.
);

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`, // The sub-path of the repo API url.
	"POST", // The API request method.
	myData // The data to send with the request.
);
1.1.1

11 months ago

1.0.8

11 months ago

1.0.7

11 months ago

1.0.6

11 months ago

1.0.5

11 months ago

1.0.4

11 months ago

1.0.3

11 months ago

1.0.2

11 months ago