1.2.1 • Published 7 years ago

grunt-ftp-push v1.2.1

Weekly downloads
655
License
-
Repository
github
Last release
7 years ago

grunt-ftp-push Build Status

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

This repo is publically maintained

The orignal owner is no longer using Grunt and does not have time to maintain this anymore. If anyone is interested in maintaining this and taking ownership, please open an issue and let us know that you'd like to be added as a contributor.

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.

You also have the option of specifying the username in your run command. This is especially useful when you have multiple users on your project, or you don't wish to store the credentials.

Gruntfile.js:

username: grunt.option('ftp-user') || 'anonymous',

Command line:

grunt --ftp-user=myUser

password

Type: String Default: None Required: false

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

You also have the option of specifying the password in your run command. This is especially useful when you have multiple users on your project, or you don't wish to store the credentials.

Gruntfile.js:

password: grunt.option('ftp-pass') || '@anonymous',

Command line:

grunt --ftp-pass=myPassWord1

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.

incrementalUpdates

Type: Boolean Default: true Required: false

Allows for files to be incrementally pushed based on their modified times.

hideCredentials

Type: Boolean Default: true Required: false

Does not show credentials in the console output. NOTE: debug mode runs jsftp in debug mode and this has no affect on that.

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":"myUserName@gmail.com",
		"password":"password123456"
	},
	"serverB":{
  		"username":"myOtherUsername@gmail.com",
  		"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: 'test/' }

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

Please add unit tests in the root of the test folder for any new or changed functionality and please try to make sure that npm test will pass before submitting a pull request.

Release History

1.2.1

7 years ago

1.2.0

7 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.0

8 years ago

0.4.4

8 years ago

0.4.3

9 years ago

0.4.2

9 years ago

0.4.1

9 years ago

0.4.0

9 years ago

0.3.6

9 years ago

0.3.4

9 years ago

0.3.2

9 years ago

0.3.0

9 years ago

0.2.8

9 years ago

0.2.6

9 years ago

0.2.4

10 years ago

0.2.3

10 years ago

0.2.2

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.3

10 years ago

0.1.2

11 years ago

0.1.1

11 years ago

0.1.0

11 years ago