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

Add option to deploy chosen file without parent directory

Open kwmlodozeniec opened this issue 7 years ago • 8 comments

Whenever I deploy a single file plugin copies to file across along with its parent folder. Can we have an option which disables that behaviour? I looked through the wiki and I could not find anything about getting the setting right to eliminate this behaviour.

kwmlodozeniec avatar Jun 02 '17 08:06 kwmlodozeniec

@kwmlodozeniec

Can a mapping help?

mkloubert avatar Jun 02 '17 08:06 mkloubert

On my Windows machine, I have a workspace folder with several folders, each with several files, I want to be able to send individual files across to my remote Linux machine. I played around with the mapping parameter but it does not seem to be helping in any way.

kwmlodozeniec avatar Jun 02 '17 09:06 kwmlodozeniec

Can you give me some examples?

mkloubert avatar Jun 02 '17 09:06 mkloubert

Windows machine workspace C:\Proj1\ has folders F1, F2, and F3. Each folder has some files. Whenever I deploy any of the files they get uploaded to the target along with their parent folder. Let's say F1 has file A inside, when I deploy A to target it creates folder F1 on the target and then puts the file I want to deploy in that folder so I get location_on_taget/F1/A

"targets": [
            {
                "type": "sftp",
                "name": "Linux Machine",
                "description": "Linux machine folder",
                "dir": "/home/user/app",
                "host": "10.50.12.110", "port": 22,
                "user": "user", "password": "pass",

                "mappings": [
                    {
                        "source": "\\",
                        "target": "/"
                    }
                ]
            }
        ]

kwmlodozeniec avatar Jun 02 '17 10:06 kwmlodozeniec

@kwmlodozeniec

Would you like to upload the files inside F1, F2 and F3 relative to /home/user/app?

If so, you should do the following:

{
    "deploy": {
        "targets": [
            {
                // ...

                "mappings": [
                    {
                        "source": "/F1",
                        "target": "/"
                    },
                    {
                        "source": "/F2",
                        "target": "/"
                    },
                    {
                        "source": "/F3",
                        "target": "/"
                    }
                ]
            }
        ]
    }
}

The paths of source properties are relative to your workspace.

The paths of target properties are relative to /home/user/app.

mkloubert avatar Jun 04 '17 18:06 mkloubert

That works but it means I need to list all subfolders in my workspace and update the setting file after adding more folders.

kwmlodozeniec avatar Jun 05 '17 07:06 kwmlodozeniec

My idea is to add a new, optional setting to the target mappings like isRegEx:

{
    "deploy": {
        "targets": [
            {
                // ...

                "mappings": [
                    {
                        "isRegEx": true,
                        "source": "^(\\/F[0-9]+)$",

                        "target": "/"
                    }
                ]
            }
        ]
    }
}

This would handle the value of source property as regular expression.

mkloubert avatar Jun 05 '17 08:06 mkloubert

Okay that would provide some workaround for more complex situations. However, for folders where user would like this kind of behaviour by default for all subfolders it would be easier just to have some flag let's say "flat": true, this way one would not have to write a regex to enable flat upload behaviour.

kwmlodozeniec avatar Jun 05 '17 11:06 kwmlodozeniec