Coder Social home page Coder Social logo

grunt-ftp-push's Introduction

grunt-ftp-push

Deploy your files to a FTP server
Notice: Currently SFTP is not supported

Getting Started

This plugin requires Grunt ~0.4.1

If you haven't used Grunt before, be sure to 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 with this command:

npm install grunt-ftp-push --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-ftp-push');

The "ftp_push" task

Overview

In your project's Gruntfile, add a section named ftp_push to the data object passed into grunt.initConfig().

grunt.initConfig({
  ftp_push: {
    your_target: {
      options: {
		authKey: "serverA",
    	host: "sample.server.com",
    	dest: "/html/test/",
    	port: 21
      },
      files: [
        {
          expand: true,
          cwd: '.',
          src: [
            ".gitignore",
            "package.json",
            "README.md",
            "test/**"
          ]
        }
      ]
    }
  }
})

Options

authKey

Type: String
Default: None
Required: false

Name of authKey that will be used for your credentials to access the FTP server. This name should match the name of the credentials you want to use in the .ftpauth file.

host

Type: String
Default: None
Required: true

URL host of your FTP Server.

dest

Type: String
Default: None
Required: true

Destination of where you want your files pushed to, relative to the host.

port

Type: Number
Default: 21
Required: false

Port for accessing the FTP server.

username

Type: String
Default: None
Required: false

If no authKey and .ftpauth file is provided, you can specify username here.

password

Type: String
Default: None
Required: false

If no authKey and .ftpauth file is provided, you can specify password here.

keepAlive

Type: Number
Default: 60000
Required: false

Duration of JSFTP's keep alive to avoid session timeouts.

debug

Type: Boolean
Default: false
Required: false

Enable debug mode for the JSFTP module to allow for verbose console messages.

Usage Examples

Sample .ftpauth file

This file should be named .ftpauth and be in the same directory as your Gruntfile.js. It is a JSON object with an "authKey" that has a username and password for it's value. Use the following as a guide for setting up your file.

{
	"serverA":{
		"username":"[email protected]",
		"password":"password123456"
	},
	"serverB":{
  		"username":"[email protected]",
  		"password":"12345Pass"
  	}
}

Required Options

Currently the host and dest options are the only two required for this plugin to function correctly. If any of the required options are omitted, the plugin will abort with a warning informing you that you did not specify all the necessary requirements.

Optional Options

In your options, you may choose not to set up an .ftpauth file and not have an authKey present in your options. You will probably then need to specify the username and password in the options object instead. If you don't, the plugin will attempt to use an anonymous login.

Specifying the username and password within the options object would look like the following:

options: {
	username: "myUsername",
	password: "myPassword",
    host: "sample.server.com",
    dest: "/html/test/",
    port: 21
}

Extras

You can now specify a destination inside your files objects like so:

{expand: true,cwd: 'test',src: ['**/*']},
{expand: true,cwd: 'tasks',src: ['**/*'], dest: 'tasks/' }

This will allow you to configure where you push your code in case you want to push to a diretory structure that is different from your local one. The dest here MUST be relative to the root destination.

Dependencies

This plugin uses Sergi Mansilla's jsftp node.js module.

Coming Soon

Adding in Unit Tests for my sanity
More Examples in the README to show different ways of using it
Possibly adding in support for SFTP

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Release History

  • 2015/05/20 - v 0.3.4 Merged fix for empty folder structure being created. #24
  • 2015/01/15 - v 0.3.2 Added debug option, updated readme, updated jsftp to 1.3.9
  • 2015/01/13 - v 0.3.0 Minor typo caused patch to work incorrectly
  • 2015/01/13 - v 0.2.8 Patch for deeply nested files throwing errors
  • 2014/12/22 - v 0.2.6 Added in option for keepAlive, default is 60000 (60 seconds), added in option for multiple destinations specified for each file object provided, if no dest is provided, it defaults to the dest specified in the options #4 & #13.
  • 2014/07/24 - v 0.2.4 Fixed issue introduced with latest fix, added fix to remove cwd from path of file being pushed so they are pushed to the expected location. Other minor fixes and enhancements.
  • 2014/07/20 - v 0.2.2
    • Fixes for getting credentials correctly.
    • Creating directories correctly from dest if they don't exist.
    • Handling '/' appropriately in all cases.
    • Better error handling, restructured code, and more detailed comments.
    • Upgraded to latest jsftp(v 1.3.1). #8
    • Updated documentation for username and password.
  • 2014/07/10 - v 0.2.1 Fixed issue from latest patch where it was not correctly creating directories in provided filepaths from patterns. As well as #7 & #9 
  • 2014/07/03 - v 0.2.0  #6  Fixed issue with pushing files from root directory when cwd is set to '.' or './'

grunt-ftp-push's People

Contributors

bruce17 avatar ivoberg avatar liuyuns avatar mattcodez avatar robert-w avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.