rokucommunity / vscode-brightscript-language

A Visual Studio Code extension for Roku's BrightScript language
MIT License
110 stars 40 forks source link

Need an option to include extra files in deploy #5

Closed kbunch closed 5 years ago

kbunch commented 6 years ago

We include other files in our deploy, config files, etc. It seems like roku_deploy has options to add these in, but I at first glance I'm not seeing the option for the launch.json in the extension.

TwitchBronBron commented 6 years ago

This isn't the final solution, but creating a rokudeploy.json file at the root of your project should help rokudeploy know what files to include.

{
    "files": [
         "source/**/*.*",
          "components/**/*.*",
          "images/**/*.*",
          "manifest",
          "YOUR_FILES_GLOB_HERE"
    ]
}

I'm definitely open to adding those options to the launch.json. Can you think of a scenario where where we would ever need to exclude parts of the original globs (source, components, images, manifest)? If not, then how about extraDeployFiles, which is an array of globs to be used in addition to the standard list?


{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "brightscript",
            "request": "launch",
            "name": "BrightScript Debug: Launch",
            "host": "192.168.1.17",
            "password": "password",
            "rootDir": "${workspaceFolder}",
            "extraDeployFiles": [
                  "EXTRA_FILES_GLOB_1",
                  "EXTRA_FILES_GLOB_2"
             ],
            "consoleOutput": "full",
            "stopOnEntry": false
        }
    ]
}
kbunch commented 6 years ago

@TwitchBronBron Best scenario would be defining files and what the would map to in the end output vs simply the files to include (since some mappings might be different). Currently we have custom build scripts that create "flavors" of the app. For example, we may have flavors/shared/resources/fonts flavors/spanish/prod/resources/config/config.json flavors/spanish/dev/resources/config/config.json

We'd want to map each resources folder to the root resources/..... We'd merge shared and prod or shared and dev. By allowing mapping of the files/folders we could pull this off with the extension by simply having different configurations. ex: spanish-dev, spanish-prod, english-prod, etc

Also to the point of your question. At times the manifest may not be in the root, but rather in one of the flavor folders

kbunch commented 6 years ago

It appears that adding a rokudeploy.json doesn't work, but the files property although "not supported" does work as a pass thru. The only issue is that the file paths don't all resolve correctly and we can't map them. Thus it seems like the change may be less on this project and more on roku deploy. Looking into this some.

kbunch commented 6 years ago

@TwitchBronBron I was able to make a simple change to the roku deploy script where rather than create absolute paths for ever file within a folder, etc that it just copied complete directories (which is probably way more efficient). In addition, I allowed the definition of src and dest for the files entry. All of this works like a charm and makes me very happy. Hopefully you can add this in and make it official. Below is a sample of what a launch.json might look like with various stubs so you can see what I'm doing

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "brightscript",
            "request": "launch",
            "name": "flavor1-staging",
            "stopOnEntry": true,
            "host": "XXXXXX",
            "password": "XXXXXX",
            "rootDir": "${workspaceFolder}",
            "files" : [
                {
                    "src":"flavors/flavor1/manifest", 
                    "dest" : "manifest"
                },
                {
                    "src":"flavors/flavor1/resources", 
                    "dest" : "resources"
                },
                {
                    "src":"components", 
                    "dest" : "components"
                },
                {
                    "src":"source", 
                    "dest" : "source"
                },
                {
                    "src":"flavors/flavor1/staging/ADBMobileConfig.json", 
                    "dest" : "ADBMobileConfig.json"
                },
                {
                    "src":"flavors/flavor1/staging/config.json", 
                    "dest" : "resources/config.json"
                },
            ],
            "consoleOutput": "normal"
        }
    ]
}
TwitchBronBron commented 6 years ago

I like it! Would you be willing to submit a pull request to the roku-deploy project with your changes? Then I will update the task information for this extension to make it more obvious which roku-deploy settings can be specified in the launch configuration.

TwitchBronBron commented 5 years ago

@kbunch I finally got some time to put this together. I updated the roku-deploy project with your proposed {src;dest;} concept. Could you npm install the latest version of roku-deploy (v0.2.0-beta1) directly in your project and run a few tests to make sure it solves your issues? I don't want to release a new version of vscode-brightscript until I know that roku-deploy solves your issue.

avoltis commented 5 years ago

Hi @TwitchBronBron , i wanted to use the same feature, but it gives me an error when trying to add a config file with the "file" property: Property files is not allowed.

Did the same config as {src;dest;} concept but got (Path must be a string. Recieved {src: "manifest", dest: "manifest"})

Any suggestions?

TwitchBronBron commented 5 years ago

@avoltis, this functionality only exists in the roku-deploy package right now, and is not yet in the vscode-brightscript-language extension. I was hoping that @kbunch would verify that it solves his needs using just roku-deploy, then I'll release a new version of vscode-brightscript-language with the upgraded roku-deploy package.

It would be helpful if you could pull down the latest beta version of roku-deploy from npm and bundle your app, see if the new functionality solves your deployment needs.

avoltis commented 5 years ago

Hi @TwitchBronBron , just tested with rokudeploy.json included extra files and it is working fine :) let us know when you release the new version 👍 Attached config: image

TwitchBronBron commented 5 years ago

@avoltis,@kbunch, I just released version 1.2.1 of the extension which includes this change. Can you test and make sure it's working?

avoltis commented 5 years ago

@TwitchBronBron hi, yeah i did test it this morning. It is working 👍 Thank you !

kbunch commented 5 years ago

My apologies, I ran an Ironman this past weekend and have been in CT this week with a client. I'll check when I get home to see if its working how we tweaked it. Many thanks ahead of time!

kbunch commented 5 years ago

@TwitchBronBron its working 👍. Have a new request now ;). We write test files to run various tests while we are writing out all the logic. We stuff all of those files under components/test. These get pushed out to the end zip unless we exclude them in some way. Wondering if it makes sense to add an exclude value as a property to src, dest object OR if we add a way to run a post process node script. Thoughts?

TwitchBronBron commented 5 years ago

I think you can accomplish this specific use case using a glob pattern (which roku-deploy already supports).

Change your glob pattern for the components folder to this (include all subfolders EXCEPT the test folder):

{
   "src": "components/!(test)/**/*'",
   "dest": ""
}

Does that solve your issue?

kbunch commented 5 years ago

@TwitchBronBron That doesn't seem to work, trying different patterns, but I can't get it to move all the subfolders over to the components directory. We have folders like... yourdomain/app/content/utils/Foo.brs. It ends up trying to put the sub folders at the root and then fails. For example it might look like content/utils/Foo.brs and misss the yourdomain/app directories