Zaid-Ajaj / Femto

Femto is a CLI tool that automatically resolves npm packages used by Fable bindings
153 stars 13 forks source link

[Feature] Introduce one "install" command to rule them all #54

Closed Zaid-Ajaj closed 5 years ago

Zaid-Ajaj commented 5 years ago

Introduce install command that unifies package installation between nuget and paket, then executes --resolve afterwards to install potentially required npm packages.

Workflow of femto install <package>

1 - Paket

Detect paket usage by checking the existence of paket.references file. if the file exists then check which dependency group should be used by parsing the first line of the of paket.references and extracting the used group from it, if no dependency group is used, then use Main as the default group. femto install <package> will then compute and execute the paket command

paket add <package> --group <deletected-group> --project <femto-input-project>

2 - Nuget

if no paket.references is found, then femto install <package> will issue the command dotnet add package <package> and resolve required dependencies afterwards

Propagate the use of --version

The command femto install <package> --version <version> propagates the --version <version> parameter to both the paket and nuget install commands

Proposal: install paket if it is not installed or tell the user to install it?

Detect whether paket is installed using paket --version and install it using dotnet tool install paket -g or just show an error message to the user telling him or her that they should install paket and giving them the required download link or download commands.

@MangelMaxime @alfonsogarciacaro What do you guys think?

MangelMaxime commented 5 years ago

In general, I am in favour of having a tool that does only one job, the same goes for libraries, etc. So I think Femto should be focused only on checking the npm dependencies validity.

Also, paket is not always installed as a global tool. People can install it under .paket/paket.exe or even at the root of their repo, etc.

It seems easy to break the paket installation check.

Zaid-Ajaj commented 5 years ago

In general, I am in favour of having a tool that does only one job, the same goes for libraries, etc.

In general, I agree but existing tools make it complicated to install a package, depending on the project structure, there different ways to do the same thing with variables :

paket * yarn | paket * npm | nuget * yarn | nuget * npm

I want to abstract that away and lower the entry barrier when it comes to installing packages.

Also, paket is not always installed as a global tool. People can install it under .paket/paket.exe or even at the root of their repo, etc.

We can recursively search for a .paket/paket.exe file since paket.dependencies file is always sibling to .paket directory, if it is there, then we use it, otherwise we use the global paket command after checking it exists using paket --version, if it then does not exist, then we tell the user to install paket anyway they like (global tool vs. local in the repo)

alfonsogarciacaro commented 5 years ago

My comment is usually the same :) This will likely be considerable work and force you to keep Femto in sync with the changes in other tools that don't know about Femto, so it will increase the maintenance burden... but if you're up for the challenge I won't stop you :wink:

Zaid-Ajaj commented 5 years ago

It is here, see this tweet