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

@khatastroffik/grunt-git-push

v1.0.0

Published

Grunt.js plugin that execute 'git push' commands

Downloads

30

Readme

grunt-git-push

A Grunt task to execute "git push" commands

Getting Started

This plugin requires Grunt 1.1.0 (it may work with some older versions, though not tested).

If you haven't used Grunt before, please check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin following the instructions below.

Conventional installation

This Grunt plugin should be installed as a development dependency of your project:

npm install --save-dev @khatastroffik/grunt-git-push

In your project's Gruntfile.js, add a section named git_push to the data object passed into grunt.initConfig(). At least one target (e.g. test below) must be defined. This target will be executed by default if no target is explicitly specified when the task is called:

grunt.initConfig({

  //...

  git_push: {
    options: {
      // define the DEFAULT options for ALL targets here
    },
    release: {
      options: {
        // define the options SPECIFIC to THIS target here
      }
    },
    test: {
      options: {
        // define the options SPECIFIC to THAT target here
      }
    }
  },

  //...

});

note: if multiple targets are defined and the task call doesn't specify any target, then ALL the defined targets will be executed in a row.

To enable i.e. load the plugin, add the following inside your Gruntfile.js file (usually after the configuration above):

// load the plugin
grunt.loadNpmTasks('grunt-git-push');

To integrate the task i.e. in order to have it called in some workflow, you may also define further (kind of meta) tasks like the following:

grunt.registerTask('pushtest', ['git_push:test']); // call the git_push task with target 'test'
grunt.registerTask('test', ['clean', 'pushtest', 'nodeunit']); // call the 'pushtest' task above

grunt.registerTask('release', ['SOME-TASK-HERE', 'git_push:release', 'SOME-TASK-THERE']);

To make the grunt (meta) tasks available per npm, you may add some scripts in your package.jsonfile. E.g.:


"scripts": {
  "pushtest": "grunt pushtest",
  "test": "grunt test",
  "release": "grunt release"
}

Options

Grunt plugin specific option

There's are the specific options:

  • continueIfError (default = false): if set to true, allows Grunt to proceed with the next task even if "git_push" has failed.
  • verbose (defult = false): displays the executed git push command and its result.
  • debug (default = false): displays the configuration of the currently executed "git_push" task.
  • cwd (default = <empty string>): when the current working directory is specified (as string), the "git push" command will be executed in this context.

Git-push specific options

There are 2 different kind of parameters

  1. git push flags: all the flags default to false. Most of them can be set to true to enable the flag. Few of the flags may contain a string value in order to be enabled. Those flags MUST be declared in a ** flag section** (see example below).
  2. git push value parameters: the values of those parameters will be passed as-is directly to the "git push" command. These param/values are defined at the "options" root level

List of options

|section|value-Param/flag|default| |---|---|---| |<root>|remote|'origin'| |<root>|branch|'master'| |<root>|cwd|''| |<root>|verbose|false| |<root>|debug|false| |<root>|continueIfError|false| |flags|all|false| |flags|tags |false| |flags|force|false| |flags|atomic|false| |flags|delete|false| |flags|prune|false| |flags|signed|false| |flags|ipv4|false| |flags|ipv6|false| |flags|quiet|false| |flags|"dry-run"|false| |flags|"follow-tags"|false| |flags|"no-verify"|false| |flags|"set-upstream"|false| |flags|"push-option"|false| |flags|"receive-pack"|false|

IMPORTANT: some flags require to be writen including the double quotes - as displayed in the table above and demonstrated in the example configuration below!

Gruntfile Configuration Example

This is an example of the git_push task configuration using a target named "default".

(note the usage of the "all" flag, which requires the remote and branch parameters to be unset)

grunt.initConfig({

  //...
  git_push: {
    options: {
      flags: {
        "dry-run": true,
      },
      verbose: true,
      debug: true,
      continueIfError: false
    },
    default: { 
      options: {
        flags: {
          all: true,
          ipv4: true,
          "follow-tags": true,
          "no-verify": true
        },
        remote: '',
        branch: '',
        continueIfError: false
      }
    }
  },
  //...

});

Executing the task git_push as defined above will result in executing the command (debug and verbose modes are "on") in DRYRUN as:

git push --all --ipv4 --follow-tags --no-verify

and the ouput would be:

Running "git_push:default" (git_push) task
>> DRY-RUN
>> Task:  git_push
>> Target:  default
>> Options:
>>  {
>>   flags: {
>>     all: true,
>>     tags: false,
>>     force: false,
>>     atomic: false,
>>     delete: false,
>>     prune: false,
>>     signed: false,
>>     ipv4: true,
>>     ipv6: false,
>>     quiet: false,
>>     'dry-run': true,
>>     'follow-tags': true,
>>     'no-verify': true,
>>     'set-upstream': false,
>>     'push-option': false,
>>     'receive-pack': false
>>   },
>>   remote: '',
>>   branch: '',
>>   cwd: '',
>>   verbose: true,
>>   debug: true,
>>   continueIfError: false
>> }
>> Spawn Options:
>>  {}
>> Command: git push --all --ipv4 --dry-run --follow-tags --no-verify
>> Everything up-to-date
OK