vs-deploy icon indicating copy to clipboard operation
vs-deploy copied to clipboard

Deploy using sftp sync

Open mikes-gh opened this issue 7 years ago • 11 comments

netcore has a load of larger dependencies that don't often change in my app. Does this extension do sync?

eg only copy newer

mikes-gh avatar Apr 19 '17 08:04 mikes-gh

@mikes-gh

You can try to realize it by using deploy on change feature.

mkloubert avatar Apr 19 '17 09:04 mkloubert

Im sorry I dont understand

You also can set deployOnChange to (true), what means, that you have to setup deployOnSave property. If you DO NOT set useTargetList to (true), you have to setup deployOnSave property.

mikes-gh avatar Apr 19 '17 12:04 mikes-gh

@mikes-gh

Oh, thats right ... I must find a much better description for that.

  • if you set deployOnChange to (true), it will use the same targets for deploying as deployOnSave and watches for changes in files, you have defined in your package
  • in a package, you can define an explicit target list (by setting up targets setting)... to use this explicit target list, you have to set useTargetList to (true)

Where are the files, that should be deployed when they change, inside your project?

Maybe I can create an example for you.

mkloubert avatar Apr 19 '17 13:04 mkloubert

Im sorry its still very confusing for me.

deployOnChange seems the same as deployOnSave to me.

Could you explain the difference.

I am after a folder comparison (like rsync) and only deploy files that are different.

mikes-gh avatar Apr 19 '17 13:04 mikes-gh

@mikes-gh

Ah, OK.

"onSave" and "onChange" are two different kind of events.

"onSave" is explicit: The event is only fired, when you have an open document and you use the save command (e.g. CTRL + S) for it ... s. onDidSaveTextDocument of vscode API ... if that file is part of one of your packages, a deployment will be started for it

"onChange" is implicit: There is a FileSystemWatcher, very similar to .NET, that watches for all changes inside your workspace ... in that case it is not important if you or a separate service, like a C# compiler, changes files ... if there is now a file that is part of one of your packages, a deployment will be started for it

Both events run parallel. They do not care what the other does.

What you have to keep in mind for files that fits both events: If you save a document in your editor: on the one hand "onSave" is fired, because you used the "save" command of VSCode ... AND parallel the file system watcher for "onChange" is fired

mkloubert avatar Apr 19 '17 23:04 mkloubert

Thanks for clear explanation

mikes-gh avatar Apr 20 '17 07:04 mikes-gh

This bit of code looks good to use

https://github.com/robogeek/node-ssh2sync

mikes-gh avatar Apr 28 '17 09:04 mikes-gh

@mkloubert make a exemple for me! I trying with this code but onlu manual (right click menu) deploy works. On save and On Change dont works. Whats wrong in my code? my settings.json file:

{
    "deploy": {
        "packages": [
            {
                "name": "Vallefrutas Odin Theme",
                
                "deployOnChange": {
                    "files": [
                        "/assets/**/**/**"
                    ],
                    "exclude": [
                        "/**/*.less",
                        "/**/*.ts"
                    ],
                    "useTargetList": true
                },
                "deployOnSave": true,
                "targets": [ "Vallefrutas AWS EC2t" ],
                "files": [
                    "**/**/**/**/**/**/**/**/**"
                ]
            }
        ],
        "targets": [
            {
                "name": "Vallefrutas AWS EC2",
                "type": "sftp",
                "description": "A WP Theme folder on AWS EC2 instance for vallefrutas.com.br site",

                "dir": "/var/www/vallefrutas.com.br/wp-content/themes/odin/",
                "host": "ec2-xx-xxx-xxx-xxx.compute-1.amazonaws.com",
                "port": 22,
                "user": "ubuntu",
                "privateKey": "B:\\Users\\Adson\\Web\\AWS\\keypair\\vallefrutas-aws.pem",
                "closing": [
                    "sudo chown -R www-data:www-data /var/www/vallefrutas.com.br/wp-content/themes/odin"
                ],
                "ignore": [
                    "/.vscode/**/*",
                    "/.git/**/*",
                    "/src",
                    "/src/**/*",
                    "/node_modules",
                    "/node_modules/**/*",

                    "/.remote-sync.json",
                    "/.DS_Store",
                    "/Thumbs.db",
                    "/desktop.ini",
                    "/*.md",
                    "/gulpfile.js",
                    "/yarn.lock",
                    "/package.json",
                    "/.gitignore",
                    "/.bowerrc",
                    "/bower.json",
                    "/*.zip",
                    "/*.tar.gz",
                    "/*.sublime-project",
                    "/*.sublime-workspace",
                    "/.ftppass"
                ]
            }
        ]
    }
}

AdsonCicilioti avatar Jul 25 '17 21:07 AdsonCicilioti

@AdsonCicilioti

You have a typo in your target list of your package:

You defined Vallefrutas AWS EC2t, but your target is called Vallefrutas AWS EC2 (without the ending t). The mistake in your settings is, that the 'deploy on change / save' feature cannot find your target. This is the reason why it only works manually (from menu or command list).

On the other hand, the ignore property must be defined as direct child of deploy.

Try this config:

{
    "deploy": {
        "packages": [
            {
                "name": "Vallefrutas Odin Theme",
                
                "deployOnChange": {
                    "files": [
                        "/assets/**/**/**"
                    ],
                    "exclude": [
                        "/**/*.less",
                        "/**/*.ts"
                    ],
                    "useTargetList": true
                },

                "deployOnSave": true,
                
                "targets": [ "Vallefrutas AWS EC2" ],
                
                "files": [
                    "**/**/**/**/**/**/**/**/**"
                ]
            }
        ],
        
        "targets": [
            {
                "name": "Vallefrutas AWS EC2",
                "type": "sftp",
                "description": "A WP Theme folder on AWS EC2 instance for vallefrutas.com.br site",

                "dir": "/var/www/vallefrutas.com.br/wp-content/themes/odin/",
                "host": "ec2-xx-xxx-xxx-xxx.compute-1.amazonaws.com",
                "port": 22,
                "user": "ubuntu",
                "privateKey": "B:\\Users\\Adson\\Web\\AWS\\keypair\\vallefrutas-aws.pem",
                "closing": [
                    "sudo chown -R www-data:www-data /var/www/vallefrutas.com.br/wp-content/themes/odin"
                ]
            }
        ],
        
        "ignore": [
            "/.vscode/**/*",
            "/.git/**/*",
            "/src",
            "/src/**/*",
            "/node_modules",
            "/node_modules/**/*",

            "/.remote-sync.json",
            "/.DS_Store",
            "/Thumbs.db",
            "/desktop.ini",
            "/*.md",
            "/gulpfile.js",
            "/yarn.lock",
            "/package.json",
            "/.gitignore",
            "/.bowerrc",
            "/bower.json",
            "/*.zip",
            "/*.tar.gz",
            "/*.sublime-project",
            "/*.sublime-workspace",
            "/.ftppass"
        ]
    }
}

mkloubert avatar Jul 25 '17 21:07 mkloubert

Nothing yet. Now it does not even work manually.

AdsonCicilioti avatar Jul 26 '17 13:07 AdsonCicilioti

Showing this errors with a high cpu core ... 2017-07-26_104408 @mkloubert Any idea?

AdsonCicilioti avatar Jul 26 '17 13:07 AdsonCicilioti