Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discussion: LibMan CLI #77

Closed
justcla opened this issue May 2, 2018 · 4 comments
Closed

Discussion: LibMan CLI #77

justcla opened this issue May 2, 2018 · 4 comments
Labels
discussion The issue is up for discussion with the community

Comments

@justcla
Copy link
Contributor

justcla commented May 2, 2018

We are producing a CLI for LibMan. This is the current design for the v1 prototype.
Does this capture your needs?
Please respond with any suggestions or other relevant feedback.

Verb/Attribute Description Examples
--version Print the current version of the LibMan executable. Libman --version
--help (-h) Print a list of all available LibMan verbs.
If parameter supplied, will print the full details of the supplied verb. (maybe not)
Libman --help
Libman -h
Init Creates new libman.json in the current directory.

Interactive:
If the user calls “libman init” with no parameters, LibMan will enter interactive mode and prompt the user to supply a defaultProvider and defaultDestination.
The default presented to the user for defaultProvider will be “cdnjs”.
The default presented to the user for defaultDestination will be “libman”.
If the user specifies either defaultProvider or defaultDestination, there will be no interactive prompting for the other default option.


Flow:
User calls init, then edits the content in an editor.
User calls init, then calls install to add library definitions to the libman.json.
 
  • “Libman init”
  • Prompted for defaultProvider and defaultDestination. Accept defaults or change.
  • “Libman install jquery”
  • Installs jquery@3.2.1 with default provider into default destination
    o (Note: “jquery@[version]") is a cdnjs-specific identifier)

Another flow:
  • Libman init –defaultDestination scripts
  • Libman install jquery@3.2.1
  • User is prompted for provider (default “cdnjs”). After entering provider, user is prompted to save this as the defaultProvider.
  Error if libman.json already exists.
libman init
(interactive: will prompt for default provider and default destination)

libman init --defaultProvider  "cdnjs"
(non-interactive: will not specify default destination)

libman init --defaultProvider cdnjs --defaultDestination script\libman
(non-interactive)
Install Adds the specified library to the libman.json, and downloads the file/s to the specified destination.

Files attribute must always be last.

Will initialize a libman.json if one does not exist.

Will error if provider is not specified and no default provider exists.
Will error if destination is not specified and no default destination exists.
If no files are specified, the entire library is included.

For CDNJS libraries, if no version is specified with the library ID, the highest version available is used.

Install can be used to upgrade or downgrade a given library.

If a version of the library being installed already exists, fail – unless “Force” flag specified. Then will update the specified library, removing any redundant files from the previous version.
libman install jquery
(error if no default provider or destination)

libman install jquery@3.2.1jquery@3.2.1
(this assumes jquery@version is a valid identifier for the defaultProvider, or else will throw an error)

libman install jquery --provider cdnjs

libman install jquery --files "jquery.min.js" "jquery.min.js.map"  

libman install jquery --destination "scripts/jquery"  
libman install jquery --provider cdnjs --destination "scripts/jquery" --files "jquery.min.js"  
libman install jquery@1.1.1 -f
Uninstall Delete the library file/s from the specified destination, then remove the specified library config from libman.json.

Error if not exactly one library found.
libman uninstall jquery

libman uninstall jquery@3.2.1

libman uninstall jquery --provider cdnjs
Restore Downloads all files from provider and saves them to configured destination.

Error if no libman.json in folder.
libman restore
Update Updates (upgrades) the specified library (or all libraries if none specified) to the latest version.

  "-pre" flag used to fetch latest pre-release version

Will fail if specified library doesn't exist.

Note: To specify a specific version, use Install.
libman update

libman update jquery

libman update --provider cdnjs

libman update jquery@3.2.1

libman update jquery --provider cdnjs

libman update jquery -pre
Clean Delete from the local project all library files defined in libman.json.

Delete any folders that become empty after this operation.
libman clean
Cache List Print a list of all libraries that are stored in the local machine’s LibMan cache. libman cache list
Cache Clean Delete all files from the local machine's LibMan cache. libman cache clean

Switches available on all commands

Verb/Attribute Description Examples
--help (-h) Provides printed help output for the given verb. libman install –help

libman restore -h

libman cache -h
--verbosity (-v)    
--quiet (-q)    

Other root options to consider
--force
--non-interactive

LibMan Cache

LibMan will maintain a cache of all libraries downloaded in the user’s home directory (ie. C:\Users[username].libman\cache)
The libraries will be organized in folders by Provider, then provider-specific library ID.
The root of the LibMan cache can contain a settings file where machine-global settings can be defined.
Here’s an example:

image

@prafullbhosale prafullbhosale added the discussion The issue is up for discussion with the community label May 11, 2018
@mikaelweave
Copy link

Little late to the party here @justcla but just spent a good amount of time looking at this and it looks great! I'm a libman user, it fits my use cases great and have been wanting a cli for it.

One suggestion, how about the "-pre" switch on install? Use case is if a developer is installing packages through the cli and wants the pre-release from the start.

@MorenoGentili
Copy link

Excuse me, how do I search for packages from the command line? Do I actually need to visit the provider website? Maybe it could work like apt or yum, like:

libman search whatever

@MorenoGentili
Copy link

Also this part seems to be incorrect:

Updates (upgrades) the specified library (or all libraries if none specified) to the latest version.

In fact, if I just type:
libman update
I get this error: LibraryId is required for update

I'd like to see a command that just states which updates are available without actually updating anything, so I can build a LibMan extension for Visual Studio Code that periodically checks if newer versions are available and notifies them to the developer.

@jimmylewis
Copy link
Contributor

Closing this item as the CLI package has long since shipped: https://www.nuget.org/packages/Microsoft.Web.LibraryManager.Cli/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion The issue is up for discussion with the community
Projects
None yet
Development

No branches or pull requests

5 participants