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

@aurahelper/git-manager

v2.1.5

Published

Aura Helper Git Manager Module its a module to handle and manage all git operations and commands.

Downloads

450

Readme

Aura Helper Git Manager Module

Version Total Downloads Downloads/Month Issues Known Vulnerabilities Code Size License

The Git Manager Module has an util methods to handle and manage git repository and has features to use in Aura Helper Framework. Yo can fetch data, list branches, get commits or get diffs from two branches, tags, commits...

You can use Aura Helper Metadata Factory Module @ah/metadata-factory to create a Metadata JSON Object from the Git diffs result, to create a package with Aura Helper Package Generator Module @ah/package-generator to create de package and destructive files from git changes to deploy or delete from your org. If you want, can use too the Aura Helper Ignore Module @ah/ignore to avoid deploy or delete some metadata types. With this workflow, refactor code, work with git and teams or implement Continuous Integration among other development processes and tasks are easy.

GitManager Class

Class with util methods to handle and manage git repository and has features to use in Aura Helper Framework. Yo can fetch data, list branches, get commits or get diffs from two branches, tags, commits...

Can cobine this module with @ah/metadata-factory, @ah/package-generator and @ah/ignore to refactor code, work with git and teams or implement Continuous Integration among other development processes and tasks easy.

Class Members

Fields

The fields that start with _ are for internal use only (Does not modify this fields to a correct GitManager work). To the rest of fields, setter methods are recommended instead modify fields.

projectFolder

Path to the project under a git repository

  • string

Constructors

constructor(projectFolder)

Constructor to instance a new GitManager object. All parameters are optional and you can use the setters methods to set the values when you want.

Parameters:

  • projectFolder: Path to the ignore file
    • string

Methods


setProjectFolder(projectFolder)

Method to set the git project folder path

Return:

Return the GitManager instance

  • GitManager

Examples:

Set Project folder

    import { GitManager } from '@aurahelper/git-manager';

    const gitManager = new GitManager();
    gitManager.setProjectFolder('path/to/project/root');

getUserName()

Method to get the User Name set on git config

Return:

Return a String promise with the Git User Name

  • Promise<string>

Throws:

This method can throw the next exceptions:

  • WrongDirectoryPathException: If the project folder is not a String or can't convert to absolute path
  • DirectoryNotFoundException: If the project folder not exists or not have access to it
  • InvalidDirectoryPathException: If the project folder is not a directory
  • OSNotSupportedException: When run this processes with not supported operative system

Examples:

Get git user name

    import { GitManager } from '@aurahelper/git-manager';
    
    const gitManager = new GitManager('path/to/project/root');

    gitManager.getUserName().then((username) => {
        console.log(username);
    }).catch((error) => {
        // handle error
    });

getUserEmail()

Method to get the User Email set on git config

Return:

Return a String promise with the Git User Email

  • Promise<string>

Throws:

This method can throw the next exceptions:

  • WrongDirectoryPathException: If the project folder is not a String or can't convert to absolute path
  • DirectoryNotFoundException: If the project folder not exists or not have access to it
  • InvalidDirectoryPathException: If the project folder is not a directory
  • OSNotSupportedException: When run this processes with not supported operative system

Examples:

Get git user email

    import { GitManager } from '@aurahelper/git-manager';
    
    const gitManager = new GitManager('path/to/project/root');

    gitManager.getUserEmail().then((userEmail) => {
        console.log(userEmail);
    }).catch((error) => {
        // handle error
    });

getAuthorName()

Method to get the Author Name set on git config

Return:

Return a String promise with the Git Author Name

  • Promise<string>

Throws:

This method can throw the next exceptions:

  • WrongDirectoryPathException: If the project folder is not a String or can't convert to absolute path
  • DirectoryNotFoundException: If the project folder not exists or not have access to it
  • InvalidDirectoryPathException: If the project folder is not a directory
  • OSNotSupportedException: When run this processes with not supported operative system

Examples:

Get git author name

    import { GitManager } from '@aurahelper/git-manager';
    
    const gitManager = new GitManager('path/to/project/root');

    gitManager.getAuthorName().then((authorName) => {
        console.log(authorName);
    }).catch((error) => {
        // handle error
    });

getAuthorEmail()

Method to get the Author Email set on git config

Return:

Return a String promise with the Git Author Email

  • Promise<string>

Throws:

This method can throw the next exceptions:

  • WrongDirectoryPathException: If the project folder is not a String or can't convert to absolute path
  • DirectoryNotFoundException: If the project folder not exists or not have access to it
  • InvalidDirectoryPathException: If the project folder is not a directory
  • OSNotSupportedException: When run this processes with not supported operative system

Examples:

Get git author email

    import { GitManager } from '@aurahelper/git-manager';

    const gitManager = new GitManager('path/to/project/root');

    gitManager.getAuthorEmail().then((authorEmail) => {
        console.log(authorEmail);
    }).catch((error) => {
        // handle error
    });

getCommitterName()

Method to get the Committer Name set on git config

Return:

Return a String promise with the Git Committer Name

  • Promise<string>

Throws:

This method can throw the next exceptions:

  • WrongDirectoryPathException: If the project folder is not a String or can't convert to absolute path
  • DirectoryNotFoundException: If the project folder not exists or not have access to it
  • InvalidDirectoryPathException: If the project folder is not a directory
  • OSNotSupportedException: When run this processes with not supported operative system

Examples:

Get git committer name

    import { GitManager } from '@aurahelper/git-manager';

    const gitManager = new GitManager('path/to/project/root');
    
    gitManager.getCommitterName().then((committerName) => {
        console.log(committerName);
    }).catch((error) => {
        // handle error
    });

getCommitterEmail()

Method to get the Committer Email set on git config

Return:

Return a String promise with the Git Committer Email

  • Promise<string>

Throws:

This method can throw the next exceptions:

  • WrongDirectoryPathException: If the project folder is not a String or can't convert to absolute path
  • DirectoryNotFoundException: If the project folder not exists or not have access to it
  • InvalidDirectoryPathException: If the project folder is not a directory
  • OSNotSupportedException: When run this processes with not supported operative system

Examples:

Get git committer email

    import { GitManager } from '@aurahelper/git-manager';

    const gitManager = new GitManager('path/to/project/root');

    gitManager.getCommitterEmail().then((committerEmail) => {
        console.log(committerEmail);
    }).catch((error) => {
        // handle error
    });


fetch()

Method to fetch repository data into your local Salesforce gitr project

Return:

Return an empty promise when finish fetch process

  • Promise<void>

Throws:

This method can throw the next exceptions:

  • WrongDirectoryPathException: If the project folder is not a String or can't convert to absolute path
  • DirectoryNotFoundException: If the project folder not exists or not have access to it
  • InvalidDirectoryPathException: If the project folder is not a directory
  • OSNotSupportedException: When run this processes with not supported operative system

Examples:

Fetch data to the local project

    import { GitManager } from '@aurahelper/git-manager';

    const gitManager = new GitManager('path/to/project/root');

    gitManager.fetch().then(() => {
        // data retrieved
    }).catch((error) => {
        // handle error
    });

getBranches()

Method to get branch names from the Salesforce git repository

Return:

Returns a promise with an object list with branch name and active status

  • Promise<GitBranch[]>

Throws:

This method can throw the next exceptions:

  • WrongDirectoryPathException: If the project folder is not a String or can't convert to absolute path
  • DirectoryNotFoundException: If the project folder not exists or not have access to it
  • InvalidDirectoryPathException: If the project folder is not a directory
  • OSNotSupportedException: When run this processes with not supported operative system

Examples:

Get branches from git project

    import { GitManager } from '@aurahelper/git-manager';

    const gitManager = new GitManager('path/to/project/root');

    gitManager.getBranches().then((branches) => {
        console.log(branches);
        // [{ name: 'master', active: false }, { name: 'branch1', active: true }, {...}]
    }).catch((error) => {
        // handle error
    });

getTags(sortField)

Method to list all git tags. You can also sort by field

Parameters:

  • sortField: Field to sort the result (Optional)
    • String

Return:

Returns a promise with a list of tags

  • Promise<GitTag[]>

Throws:

This method can throw the next exceptions:

  • WrongDirectoryPathException: If the project folder is not a String or can't convert to absolute path
  • DirectoryNotFoundException: If the project folder not exists or not have access to it
  • InvalidDirectoryPathException: If the project folder is not a directory
  • OSNotSupportedException: When run this processes with not supported operative system

Examples:

Get tags from git project

    import { GitManager } from '@aurahelper/git-manager';

    const gitManager = new GitManager('path/to/project/root');

    gitManager.getTags().then((tags) => {
        console.log(tags);
        // [{ name: 'v.1.0.0', description: 'tag description' }, { name: 'v.1.0.1', description: 'tag description' }, {...}]
    }).catch((error) => {
        // handle error
    });

getCommits()

Method to get the commits data from the Salesforce git repository

Return:

Returns a promise with list of Commit objects

  • Promise<Commit[]>

Throws:

This method can throw the next exceptions:

  • WrongDirectoryPathException: If the project folder is not a String or can't convert to absolute path
  • DirectoryNotFoundException: If the project folder not exists or not have access to it
  • InvalidDirectoryPathException: If the project folder is not a directory
  • OSNotSupportedException: When run this processes with not supported operative system

Examples:

Get commits data from git project

    import { GitManager } from '@aurahelper/git-manager';

    const gitManager = new GitManager('path/to/project/root');

    gitManager.getCommits().then((commits) => {
        for(const commit of commits){
            console.log(commit.pointer);
            console.log(commit.author);
            console.log(commit.authorEmail);
            console.log(commit.date.dayName);
            console.log(commit.date.monthName);
            console.log(commit.date.day);
            console.log(commit.date.time);
            console.log(commit.date.year);
            console.log(commit.date.timeoffset);
            console.log(commit.date.dateStr);
            console.log(commit.title);
            console.log(commit.message);
        }
    }).catch((error) => {
        // handle error
    });

getDiffs(source, target)

Method to get a list of GitDiff object with the differences between two branches, commits, tags...

Parameters:

  • source: Source branch name, tag or commit for get diffs
    • string
  • target: Target branch name, tag or commit for get diffs
    • string

Return:

Returns a promise with GitDiffs objects list with the difference data

  • Promise<GitDiff[]>

Throws:

This method can throw the next exceptions:

  • WrongDirectoryPathException: If the project folder is not a String or can't convert to absolute path
  • DirectoryNotFoundException: If the project folder not exists or not have access to it
  • InvalidDirectoryPathException: If the project folder is not a directory
  • OSNotSupportedException: When run this processes with not supported operative system
  • DataRequiredException: If source is not provided

Examples:

Get diffs from two branches

    import { GitManager } from '@aurahelper/git-manager';

    const gitManager = new GitManager('path/to/project/root');

    gitManager.getDiffs('branch1', 'master').then((diffs) => {
        for(const diff of diffs){
            console.log(diff.path);
            console.log(diff.mode);
            console.log(diff.addChanges); // Array with every added line per file
            console.log(diff.removeChanges);  // Array with every removed line per file
        }
    }).catch((error) => {
        // handle error
    });