npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

git-interface

v2.1.2

Published

some interfaces for work with git repository

Downloads

5,673

Readme

git-interface

Interface to work with a git repository in node.js

Installation

$ npm install git-interface --save

Usage

const { Git } = require('git-interface');

const git = new Git({
	dir: '/path/to/repository' //default path is current directory
});
...

Documentation

.setDir(dir: string)

Set path to repository

git.setDir('/path/to/repository');

.init()

Initializes new git repo

git.init();

.clone(repository: string, dest: string)

clone repository repository to path dest

await git.clone('[email protected]:yarkeev/git-interface.git', 'git-interface');

.checkout(branchName: string)

Checkout to branch branchName

await git.checkout('master');

.updateSubmodules(init: boolean = true, recursive: boolean = true)

Updates the git submodules:

await git.updateSubmodules();

.commit(message: string)

Commit changes with message

await git.commit('message for annotate');

.pull()

Pull current branch from origin

await git.pull();

Pull branch feature1 from remote test with rebase (-r) option

await git.pull('test', { branch: 'feature1', rebase: true });

.push()

Push current branch to origin

await git.push();

.add()

Add all new files to VCS

await git.add();

.merge(branchName: string, mergeOptions?: string)

Merge branch branchName to the current branch with flags mergeOptions

await git.merge('branch-name');
await git.merge('branch-name', '--squash');

.fetch()

Download objects and refs from origin

await git.fetch();

.addRemote(name: string, url: string)

Add a remote

await git.addRemote('origin', '[email protected]:yarkeev/git-interface.git');

.setRemote(name: string, url: string)

Set the url of a remote

await git.setRemote('origin', '[email protected]:yarkeev/git-interface.git');

.getRemotes()

Gets list of remote names

await git.getRemotes();

.getRemoteUrl(name: string)

Gets a url of a remote by name

await git.getRemoteUrl('origin');

.reset()

Reset uncommitted changes

await git.reset();

.getHash(fileName: string)

Getting hash commit was last modified

const hash = await git.getHash('path/to/file');

.diffMaster(fileName: string)

File comparison fileName with master

const diff = await git.diffMaster('path/to/file');

.getBranchName()

Get name of the current brunch

const branch = await git.getBranchName();

.createBranch(branchName: string)

Create branch with name branchName

await git.createBranch('new-branch');

.deleteBranch(branchName: string)

Delete branch with name branchName

await git.deleteBranch('existing-branch');

.getDiffByRevisionFileList(revision: string)

Getting a list of files that have changed relative revision

const diffFileList = await git.getDiffByRevisionFileList('5e19a1d3c386a2607885627f3774d3d7746b60de');

.getConflictList()

Get list of conflicted files after merge

const conflictList = await git.getConflictList();

.getUncommittedList()

Get list of uncommitted files

const uncomittedList = await git.getUncommittedList();

.getLastChanges()

Getting a list of files that have changed in the last commit

const lastChanges = await git.getLastChanges();

.removeLocalBranch(branchName: string)

Remove local branch branchName

await git.removeLocalBranch('branch-name');

.removeRemoteBranch(branchName: string)

Remove branch branchName from origin

await git.removeRemoteBranch('branch-name');

.getLocalBranchList()

Get list of local branches

const branches = await git.getLocalBranchList();

.getRemoteBranchList()

Get list of remote branches

const branches = await git.getRemoteBranchList();

.getTimeOfLastCommit(branchName: string)

Get time of last commit in branch

const timeOfLastCommit = await git.getTimeOfLastCommit('branch-name');

.getHashOfLastCommit(branchName: string)

Get hash of last commit in branch

const hashOfLastCommit = await git.getHashOfLastCommit('branch-name');