gtg092x / gulp-sftp

Gulp SFTP Deploy
140 stars 61 forks source link

Clear target folder on remote server #32

Open te-gpm opened 9 years ago

te-gpm commented 9 years ago

I'm using gulp-sftp to upload the current state of a project to a staging server. Is it possible to clean (e.g. delete all content) of the target folder on the remote machine before uploading? Since I have a lot of changing files and file structures the target folder gets extremely cluttered with files that have since been moved, renamed or deleted.

sebromero commented 9 years ago

+1 or at least the possibility to overwrite folders would be awesome.

te-gpm commented 9 years ago

I ended up using gulp-rsync which supports a clean parameter that will delete files not included in the synced folder. https://www.npmjs.com/package/gulp-rsync

I'm missing an option to store credentials in a separate file, but maybe this will be included in gulp-sftp in the future :)

sebromero commented 9 years ago

Thx @te-gpm , rsync isn't an option for me because I use a shared hosting environment which doesn't offer rsync.

gtg092x commented 9 years ago

Hey all - I'm being a bad project maintainer here. I'm hesitant to dive into the feature because mistakes can end up deleting valuable assets (extra paranoid). Can I get anyone to help with its development? I'd be happy to make the change if someone can pull the branch and test it with me.

te-gpm commented 9 years ago

Hey gtg092x, unfortunately I'm pretty swamped right now, so I won't be able to help with development, but I'd be happy to help testing on a VM if you were to develop this feature :) Just drop me a line or post here if I can be of assistance.

bartvanderwal commented 8 years ago

+1! I'd also be happy to help @gtg092x. Assuming I have the time when you drop me a line. And I', using it currently, do.. Otherwise @te-gpm might have some time then.

Great work with this repo!

kaosmos commented 8 years ago

@te-gpm actually you can put the credentials in a different file already. Create a file called .sftppass.json (or whatever you prefer) in the same dir where your gulpfile.js resides and put your credentials inside it, like this:

{
  "host": "yourhost",
  "user": "youruser",
  "pass": "yourpass"
}

then use it in your gulpfile.js, like this:

var gulp = require('gulp');
var sftp = require('gulp-sftp');
var sftppass = require('./.sftppass.json');

gulp.task('default', function () {
    return gulp.src('src/*')
        .pipe(sftp(sftppass));
});

also you can ignore .sftppass.json in your version system to commit your gulfile.js without distributing your credentials around

kaosmos commented 8 years ago

@gtg092x I'm also interested in cleaning the remote dir (or move it to a backup location) and I can help you out in trying this, I'm extra paranoid too so don't worry: even if we end up deleting some precious asset I definitely have it backuped somewhere :) Maybe a good approach to this kind of things is having the ability to forward some command directly without a prebuilt method, something like the .ssh(), .sftp() or .shell() of this module: https://github.com/teambition/gulp-ssh so the advanced user can do almost everything and is responsible of his/her actions.

skrzyszewski commented 8 years ago

+1

wottpal commented 8 years ago

+1

kaosmos commented 8 years ago

@gtg092x are you still on this project?

TCB13 commented 7 years ago

I was experiencing this issue and some others, moved to gulp-rsync and it works much better. Just my 2 cents.

kaosmos commented 7 years ago

@TCB13 yes, gulp-rsync works very well but, alas, I don't have rsync available in every environment I have the pleasure to work on :)

TCB13 commented 7 years ago

@kaosmos I'm going plain old FTP when that happens. Seems to be the only viable option right now. Unfortunately. :(

kaosmos commented 7 years ago

yes and further it seems that @gtg092x has abandoned this package

ruslanxdev commented 7 years ago

+1

rudchenkos commented 7 years ago

I have implemented it in Pull Request #73

krysalead commented 6 years ago

Thanks for having implemented this feature, I was looking to it. @gtg092x can you please review and merge. Otherwise we can publish a fork with a different name

theenoahmason commented 6 years ago

Without a clean method, this is not useable in the real world.

krysalead commented 6 years ago

Hi All,

I published gulp-sftp-clean on NPM which contains the code from @rudchenkos I am using it and it does the job

Regards

wottpal commented 6 years ago

Sounds great @krysalead!