ttu / dotnet-fake-json-server

Fake JSON Server is a Fake REST API that can be used as a Back End for prototyping or as a template for a CRUD Back End.
https://ttu.github.io/dotnet-fake-json-server/
MIT License
388 stars 84 forks source link

..as a .NET Core global tool? #30

Closed alexdresko closed 6 years ago

alexdresko commented 6 years ago

https://docs.microsoft.com/en-us/dotnet/core/tools/global-tools

That would make installation and usage much easier. Thoughts? I might be able to figure out how to do it if no one else has time.

ttu commented 6 years ago

Hi and thanks for the interest!

I actually have created a package but didn't find a way to install a global tool from a local nuget package. I would have wanted to try it out before publishing it to nuget.

But I can publish it soon to NuGet and let's see how this works as a global tool. Not sure how passing parameters etc. works, but then we will see :)

alexdresko commented 6 years ago

You could try publishing it as a pre-release package. It looks like you can specify the version you want to install. Dunno if that works for pre-releases, though.

dotnet tool install -g <package-name> --version <version-number>

ttu commented 6 years ago

Actually now found a correct blog post that had commands to install the tool from a local package

dotnet pack --output ./
dotnet tool install -g MyDotNetCoreTool --add-source ./

I would like to have few opinions about naming.

Should package be listed as a FakeJsonServer? By default it is listed with the name of the assembly and it would be FakeServer, but Fake JSON Server name is more commonly used in this repo. Package name is used with install.

dotnet tool install --global FakeJsonServer

Should command name be fakejsonserver, fakeserver or fake-server?

Now application.json file is read from the current working directory. With dotnet tool it won't work as application.json is located under $HOME/.dotnet/tools (Windows), so I have to make changes to that and check that it works correctly with Docker etc.

alexdresko commented 6 years ago

As for naming, here's a list of dotnet global tools https://github.com/natemcmaster/dotnet-tools for reference. Personally, I prefer the "-" delimited name. Maybe fake-json-server, or just fake-server (because, honestly, the tool could eventually support more content types, like XML?).

ttu commented 6 years ago

Added prerelease version to NuGet. Will try to test this little bit more next week and then will release new version. https://www.nuget.org/packages/FakeServer/0.8.0-rc

Code is in branch https://github.com/ttu/dotnet-fake-json-server/tree/dotnet-tool-release

Used delimetered naming, and didn't use json in the command.

$ dotnet tool install --global FakeServer --version 0.8.0-rc
$ fake-server
ttu commented 6 years ago

Released version 0.8.0

https://github.com/ttu/dotnet-fake-json-server#install-as-a-dotnet-global-tool