vscode-sftp icon indicating copy to clipboard operation
vscode-sftp copied to clipboard

How do I upload content inside a project sub folder?

Open yehudaTiram opened this issue 1 year ago • 3 comments

In vuepress project i have a dist folder that needs to be uploaded to the production site. The dev files structure is: vuepress-starter - src - .vuepress - dist where dist is the build of the project. I want sftp to upload only the content of the dist folder to the server without creating its local files structure.

In the FAQ "How do I upload content inside a folder, but not the folder itself?" you provide a configuration example, but that does not work somehow. I set my sftp profile as: { "name": "docs", "ignore": [ ".vscode", ".DS_Store", "__debug_bin", ".exe", ".git", ".gitignore", ".history", "config.json", "private", "node_modules", ".psd" ], "profiles": { "one": { "name": "docs", "host": "xxx.xxx.xxx.xxx", "protocol": "ftp", "port": 21, "username": "xxxxx", "password": "xxxxxxxx", "remotePath": "/docs.xxxxxxxx.com/", "context": "./vuepress-starter/src/.vuepress/dist/", "watcher": { "files": "*.{js,html,css,json,ico,png,jpg,web,svg}", "autoUpload": true, "autoDelete": false }, "uploadOnSave": true, "printDebugLog": true } } } But this profile settings always creates the full folder structure in the remote host. Any idea about this issue? Thanks.

yehudaTiram avatar Feb 01 '24 10:02 yehudaTiram

I also want to know this, bump!

MatiasMunk avatar Jun 24 '24 23:06 MatiasMunk

Hey,

TL;DR

The problem is that you are trying to define the context inside the profiles object.

{
    "name": "docs",
    "ignore": [],
    "profiles": {
        "one": {
            "name": "docs",
            "host": "xxx.xxx.xxx.xxx",
            "protocol": "ftp",
            "port": 21,
            "username": "xxxxx",
            "password": "xxxxxxxx",
            "remotePath": "/docs.xxxxxxxx.com/",
            "context": "./vuepress-starter/src/.vuepress/dist/", <-------------------- HERE
            "watcher": {
                "files": "*.{js,html,css,json,ico,png,jpg,web,svg}",
                "autoUpload": true,
                "autoDelete": false
            },
            "uploadOnSave": true,
            "printDebugLog": true
        }
    }
}

The README says: Note:context and watcher are only available at root level.

I tested with and without profiles. The version without profiles is down below. Here is the fixed version with profiles:

{
    "name": "vuepress",
    "host": "localhost",
    "protocol": "sftp",
    "port": 1793,
    "context": "docs/.vuepress/dist", <-------------------- HERE
    "profiles": {
        "one": {
            "name": "docs",
            "host": "localhost",
            "remotePath": "/var/www/html/users/xxx/tmp/vuepress/"
        }
    },
    "uploadOnSave": false,
    "useTempFile": false,
    "openSsh": false,
    "username": "",
    "passphrase": "",
    "privateKeyPath": "",
    "watcher": {
        "files": "**",
        "autoUpload": true,
        "autoDelete": true
    }
}

I tried to recreate your problem. I created a fresh vuepress project with npm init vuepress vuepress-starter. After that I made a build with npm run docs:build. So we should have the same starting point. My folder structure looks like this.

$ find . -maxdepth 1 -type d
.
./.vscode
./docs
./node_modules

And the docs/.vuepress/dist folder looks like this:

$ find docs/.vuepress/dist -maxdepth 3 -type d
docs/.vuepress/dist
docs/.vuepress/dist/article
docs/.vuepress/dist/assets
docs/.vuepress/dist/category
docs/.vuepress/dist/category/categorya
docs/.vuepress/dist/category/categoryb
docs/.vuepress/dist/category/categoryc
docs/.vuepress/dist/category/history
docs/.vuepress/dist/posts
docs/.vuepress/dist/tag
docs/.vuepress/dist/tag/tag-a
docs/.vuepress/dist/tag/tag-b
docs/.vuepress/dist/tag/tag-c
docs/.vuepress/dist/tag/tag-d
docs/.vuepress/dist/tag/tag-e
docs/.vuepress/dist/tag/wwi
docs/.vuepress/dist/tag/wwii
docs/.vuepress/dist/timeline

My SFTP-Config without profiles looks like this:

{
    "name": "vuepress",
    "host": "localhost",
    "protocol": "sftp",
    "port": 1793,             
    "remotePath": "/var/www/html/users/xxx/tmp/vuepress/",
    "context": "docs/.vuepress/dist",
    "uploadOnSave": false,
    "useTempFile": false,
    "openSsh": false,
    "username": "",
    "passphrase": "",
    "privateKeyPath": "",
    "watcher": {
      "files": "**",
      "autoUpload": true,
      "autoDelete": true
    }
  }

The files uploaded to the remote-side:

$ [remote-server-xxx - tmp/vuepress]: find . -type d                                                                                                                                                   
.
./article
./assets
./category
./category/categorya
./category/categoryb
./category/categoryc
./category/history
./posts
./tag
./tag/tag-a
./tag/tag-b
./tag/tag-c
./tag/tag-d
./tag/tag-e
./tag/wwi
./tag/wwii
./timeline](url)

@Natizyskunk I think the Issue can be closed. ✌🏼

tomsour1s avatar Aug 05 '24 11:08 tomsour1s

@tomsour1s Thank you for the detailed answer. Seems like it is my bad. I'll test it. (though this project has long gone :) )

yehudaTiram avatar Aug 05 '24 11:08 yehudaTiram