liximomo / vscode-sftp

Super fast sftp/ftp extension for VS Code
MIT License
1.5k stars 260 forks source link

Upload to several hosts at the same time #107

Open vystepanenko opened 6 years ago

vystepanenko commented 6 years ago

Expected Behavior

I want to send file from one workspace to several hosts. Is there any way to do this?

I tried to do something like

[
    {
        "protocol": "sftp",
        "host": "test_host",
        "port": 22,
    },
    {
        "protocol": "sftp",
        "host": "prod_host",
        "port": 22,
]

But on upload it send file only to prod_host.

It would be great to have posibility configure several hosts and on upload vscode will ask you on what host you want to upload the file

CleoQc commented 6 years ago

I am having exactly the same issue. Only the last host is being uploaded to.

MTester2 commented 6 years ago

I am having this issue too. I think it is a matter of the 'context' being exactly the same between two hosts. I have a test machine and a prod machine. The remote paths are different on those, but the context is the same: c:\Projects\name

If I change the context on one of them to be a different folder, for example a sub folder, then both show up: c:\Projects\name c:\Projects\name\subfolder

LeMoussel commented 6 years ago

Same issue. Is it possible to upload on many hosts with same context/VS Code folder ?

vystepanenko commented 6 years ago

This config working for me

 "targets": [
            {
                "type": "sftp",
                "name": "Test",
                "description": "Test server",
                "dir": "/path",
                "host": "test_host_ip",
                "port": 22,
                "user": "username",
                "password": "password",
                "mappings": {
                    "/public": "/public"
                }
            },
            {
                "type": "sftp",
                "name": "Prod",
                "description": "Prod server",
                "dir": "/path",
                "host": "prod_host_ip",
                "port": 22,
                "user": "username",
                "password": "password",
            }
        ]
LeMoussel commented 6 years ago

What is is your config?
With sftp V1.1.3, I got "targets": Incorrect type. Expected "array".

vystepanenko commented 6 years ago

This is target section of config.

Whole config looks like


 {
    "deploy.reloaded": {
        "targets": [
            {
         ....target 1....
        },
            {
                .....target2 ....
            }
        ]
    }
} 
LeMoussel commented 6 years ago

I don't understand, sftp.json config file only accepts array like this example

[
    {
        "protocol": "sftp",
        "host": "test_host",
        "port": 22
    },
    {
        "protocol": "sftp",
        "host": "prod_host",
        "port": 22
    }
]

Do you use vscode-deploy-reloaded extension, like this target_sftp ?

vystepanenko commented 6 years ago

sorry man, I mixed up extension

Yes I'm using vscode-deploy-reloaded

FireController1847 commented 5 years ago

@liximomo Any status on getting this added? It'd make my life a lot easier.

Also, does the extension actually currently have the ability to do more than one? If so, how would I do it?

littleji commented 5 years ago

I think there are some problem in "context" setting, I have a trick like:

[
    {
        "context": ".",
        "protocol": "sftp",
        "host": "test_host",
        "port": 22
    },
    {
        "context": "../YOUR_SRC_FILE_FOLDER",
        "protocol": "sftp",
        "host": "prod_host",
        "port": 22
    }
]
notrealdev commented 5 years ago

+1

matteusbarbosa commented 5 years ago

I was looking for something useful to watch and deploy the same files to many clients at once. doing this manually was tedious so here it goes:

for the ones who also still struggle on doing this I would strongly recommend something using the watch tool + ftp solution (vinyl,sftp.... whatever it is) as following

 'use strict';

const gulp = require('gulp');

const sass = require('gulp-sass');

const gutil = require('gulp-util');

var ftp = require( 'vinyl-ftp' );

const sourcemaps = require('gulp-sourcemaps');

const errorHandler = require('gulp-error-handle');

const logError = function(err) {
  gutil.log(err);
  this.emit('end');
};

const minify = require('gulp-minify');

const { watch } = require('gulp');

function w() {

const project_globs = ['public/dist/**', 'resources/**', 'app/**', 'config/**', 'routes/**', 'database/**'];

  watch(project_globs, function(cb) {

    var conn = ftp.create( {
      host:     'wwwfileshost',
      user:     'myselfthegrandpa',
      password: 'hardpass',
      parallel: 10,
      log:      gutil.log
  } );

  var globs = project_globs;

  // using base = '.' will transfer everything to /public_html correctly
  // turn off buffering in gulp.src for best performance

//first client
      gulp.src( globs, { base: '.', buffer: false } )
      .pipe( conn.newer( '/public_html/domains/myfirstclient/' ) ) // only upload newer files
      .pipe( conn.dest( '/public_html/domains/myfirstclient/' ) );

//second client
      gulp.src( globs, { base: '.', buffer: false } )
      .pipe( conn.newer( '/public_html/domains/mysecondclient/' ) ) // only upload newer files
      .pipe( conn.dest( '/public_html/domains/mysecondclient/' ) );

//and so on

    cb();
  });
}
exports.w = w;
botemple commented 5 years ago

This is a useful feature. feature request for more than 1 year. encounter any difficulty to implemented?

Xychun commented 5 years ago

+1

matteusbarbosa commented 5 years ago

You guy just have to start ftp.create({options}) with custom options for each host. It works.

tong3jie commented 4 years ago

+1

tingQian commented 4 years ago

+1

ruanimal commented 4 years ago

+1

shijunti19 commented 4 years ago

+1怎么还不解决

ybbbbt commented 3 years ago

I think there are some problem in "context" setting, I have a trick like:

[
    {
        "context": ".",
        "protocol": "sftp",
        "host": "test_host",
        "port": 22
    },
    {
        "context": "../YOUR_SRC_FILE_FOLDER",
        "protocol": "sftp",
        "host": "prod_host",
        "port": 22
    }
]

I make a symbolic link of my souce file folder and add to the context, which seems to work.

[
    {
        "context": ".",
        "protocol": "sftp",
        "host": "test_host",
        "port": 22
    },
    {
        "context": "../YOUR_SRC_FILE_FOLDER_SYMBOLIC_LINK",
        "protocol": "sftp",
        "host": "prod_host",
        "port": 22
    }
]