Robert-W / grunt-ftp-push

Deploy files to an FTP server as part of your Grunt workflow.
MIT License
39 stars 14 forks source link

Create and/or clean remote directory #11

Closed richardwestenra closed 10 years ago

richardwestenra commented 10 years ago

Is there any way to have the plugin clean/wipe a remote directory before pushing new files? I'm using it with grunt-rev and tend to end up with a bunch of alternate copies of my files after a while.

On an unrelated note, I've found that my setup throws an error when trying to push to a directory that does not exist yet, so I need to manually create the remote directory before pushing. Is there any way to have it automatically create directories? This is my current config setup:

ftp_push: {
  your_target: {
    options: {
      authKey: '[authkeyname]',
      host: '[hostname]',
      dest: '<%= config.dest %>'
    },
    files: [
      {
        expand: true,
        src: ['<%= config.dist %>','<%= config.dist %>/**/*']
      }
    ]
  }
}
pyrsmk commented 10 years ago

+1 for a sync mode between local and remote directories

Robert-W commented 10 years ago

I can take a look Into addin a wipe feature in, that should be pretty simple. I'm getting back from vacation tomorrow so I should be able to get to it within the next week or so. I'll put the sync on the list for next upgrades as a proper sync will take a little time.

Robert-W commented 10 years ago

@richardwestenra, can you post what your destination is? It should be creating directories for you. Have you tried specifying a current working directory in your files objects like in the readme?

richardwestenra commented 10 years ago

@Robert-W Thanks. Destination is /foo/bar/baz/ (e.g. /AgencyName/ClientName/ProjectName/)

If the 'baz' directory doesn't exist then that's fine, it will be created (as long as I have '<%= config.dist %>' set in my src array, alongside '<%= config.dist %>/**/*'). However if the bar directory doesn't exist then the transfer fails, with Fatal error: read ECONNRESET.

I've tried specifying a working directory, e.g.

    files: [
        {
            expand: true,
            cwd: '.',
            src: ['<%= config.dist %>','<%= config.dist %>/**/*']
        }
    ]

however it doesn't seem to make a difference.

Robert-W commented 10 years ago

hmmm. That should be working fine. If I set up something similar I am able to get it to work. The only reason I can think of it not doing that is if for some reason it is trying to push to a directory that does not exist, e.g. in the case of /foo/bar/baz/, pushing to baz would throw that error if /foo/bar/ had not been created first. I used the following and it worked for me with neither foo, bar, or baz being created before I ran this task.

sample: {
  options: {
    host: "staging.mysite.com",
    dest: "/foo/bar/baz/",
    username: "",
    password: ""
  },
  files: [
    {
      expand: true,
      cwd: './',
      src: [
        "test/**"
      ]
    }
  ]
}
Robert-W commented 10 years ago

Are you on version 0.2.4? That was a bug in a previous version that should be fixed.

richardwestenra commented 10 years ago

Oh! I'm on version 0.1.3. D'oh, sorry, it works now. I've changed my setup to the following, which seems to work best:

        files: [
          {
            expand: true,
            cwd: '<%= config.dist %>',
            src: ['*','**']
          }
        ]

Thank you so much for your help!

Robert-W commented 10 years ago

Awesome! I am going to close this ticket out then and I will create a new one with the wipe feature and sync feature which will be marked as an enhancement for the next version.

zeeshanjan82 commented 9 years ago

Hi Guys, Is there any way to clean or wipe the remote folder before pushing the release?

Robert-W commented 9 years ago

Hey @zeeshanjan82 at the moment it is not, that is definitely something on my list of updates. I have a ticket open marked as enhancement for exactly this feature, see here #12, As I mentioned there I am currently a little preoccupied with school and work. I am getting overloaded with school projects this semester, much more then normal, and haven't really had any free time to implement this. The plan is if I can spare some time, I will get it done asap, worst case since this seems to be the one feature most people want, I will add this in around mid december when my semester ends. I apologize if this is an inconvenience and will update ticket #12 when I start making some progress on this.