akamai / cli-netstorage

Apache License 2.0
15 stars 14 forks source link

Potential PR for adding serve from zip feature #27

Open MattMcFarland opened 1 year ago

MattMcFarland commented 1 year ago

Hello Akamai Folks! I've been using a customized version of this plugin for the last few years but really my team would prefer we stay up to date with Akamai and suggested that I submit a PR, but I wanted to ask you how best to implement this.

Because my team has no need to upload anything but a zip file, I went the "easy" route and just made this change to your upload function:

            let request = {
                    action: "version=1&action=upload&index-zip=1",
                    method: "PUT",
                    path: path,
                    body: body
            }

as you can see, I simply added &index-zip=1 - but obviously this is not the best route if we want something that works with files that aren't zipped as well.

When looking at this again, I figured there are a couple of things I could do. I could make it use a flag like --zip , but I don't see you using a pattern like this with any of the other commands. If I do use this option. would it automatically appear on the options object? So if I added --zip would options.zip be true?

Another thing I thought of is just copying this and making another function called uploadZip - it would essentially do the same thing but at the &index-zip=1 - this would allow me to not worry about options.zip, and also it would make this behave like the other commands, since all the commands seem to just take single arguments without options.

MY preference would be to use the --zip feature.. but I'm not sure if it would appear on the options object, and I'm not sure if that's the pattern you want to follow.

Could someone from the akamai team let me know what would be OK? I'll submit a PR after, and thanks!