Giter Site home page Giter Site logo

librarymanager's Introduction

Microsoft Library Manager

Install and consume 3rd-party client-side libraries with ease.

Build Status

Reasons to use LibMan

  1. For apps not currently using another package manager
  2. For projects where you think Bower and npm are overkill
  3. For developers that don't want to use Bower/Yarn or npm
  4. For developers that value simplicity in their tools
  5. For using custom or private packages/files
  6. For orchestrating file placement within your project

Reasons NOT to use LibMan

  1. Developer/team likes using tools such Bower, Yarn or npm
  2. For apps that uses WebPack or Browserify for module loading/bundling

Features

  • Add any library from cdnjs.com, jsdelivr.com, or unpkg.com
  • Add any file from file system, network share or remote URL
  • Only add the file(s) you need
  • Can install any file into any folder in your project/solution
  • Very fast

Installation

  • Fully integrated into Visual Studio 2017 and newer

  • Available as an add-in for Visual Studio for Mac

    • From the main menu, open the Extensions Manager dialog.
    • Select the Gallery tab.
    • Expand IDE extensions.
    • Select the Library Manager addin
    • Click the Refresh button if the addin is not visible.
    • Click Install… to install the addin.
    • Restart Visual Studio for Mac.

    Please read the LibMan support in Visual Studio for Mac blog post for more details

  • Available as a dotnet global tool - Microsoft.Web.LibraryManager.Cli

Getting started

Right-click any web project in Solution Explorer and hit Manage Client-side Libraries....

Context menu

This will create a libman.json file in the root of the project.

libman.json

Context menu

Right-click libman.json in Solution Explorer to access commands that help managing the libraries.

context menu libman.json

Intellisense

Edit the libman.json file to install libraries. Every time the file is saved, Visual Studio will install/restore the packages.

libman.json

See libman.json reference for more information.

Light bulbs

Inside libman.json there are light bulbs that show up with helpful commands.

Light bulbs

Road map and release notes

See the CHANGELOG for road map and release notes

Feedback

Check out the contributing page to see the best places to log issues and start discussions.

Reporting Security Issues

Please refer to SECURITY.md

librarymanager's People

Contributors

aidmsu avatar alexanderschulz-siemens avatar alexgav avatar aquastorm avatar bhsubra avatar bzhu94 avatar campersau avatar cristianosuzuki77 avatar csigs avatar danielku15 avatar davkean avatar dependabot[bot] avatar dotnet-bot avatar drgy avatar felipepessoto avatar jimmylewis avatar justcla avatar madskristensen avatar maherjendoubi avatar mlorbetske avatar phil-allen-msft avatar prafullbhosale avatar raquelsa avatar robjohnston avatar scottaddie avatar terrajobst avatar tlmii avatar toddgrun avatar tomaszpolachowski avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

librarymanager's Issues

[CLI] "libman cache clean <provider>" command doesn't produce an error message for unknown provider id

Functional impact

Customer might not realize command failed since no error message is produced, e.g. if the customer misstypes the provider id

Minimal repro steps

  1. Execute
libman cache clean foo

Expected result

Error message stating provider "foo" is not installed

Actual result

No output

Further technical details

We can get a list of the available providers, and we do give "invalid provider id" error in libman install

Discussion: LibMan CLI

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 [email protected] with default provider into default destination
    o (Note: “jquery@[version]") is a cdnjs-specific identifier)

Another flow:
  • Libman init –defaultDestination scripts
  • Libman install [email protected]
  • 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 [email protected]@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 [email protected] -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 [email protected]

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 [email protected]

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

Copying file from CDNJS that's not located in root folder

{
  "defaultProvider": "cdnjs",
  "libraries": [
    {
      "library": "[email protected]",
      "destination": "wwwroot/js",
      "files": [ "umd/react.development.js" ]
    }
  ]
}

I expected this to copy the file to my wwwroot/js folder, but it actually creates umd folder with react.development.js inside of it. Folder is created inside of wwwroot/js.

Is this expected behaviour?

[CLI] "libman clean" command deletes only deepest empty folders

Functional impact

Some empty folders are left behind. Not sure if that's by design

Minimal repro steps

  1. Install [email protected] using cdnjs into wwwroot\script\jq
  2. Execute
libman clean

Expected result

Honestly, not sure. There is a warning in the command output that empty folders will be deleted. What I am seeing is that "jq" is deleted but not "script". Should we delete empty folders all the way up to the root of the project?

Actual result

Only deepest empty folder is deleted, i.e. "jq"

Further technical details

This could be by design - a bit confusing though that we delete some empty folders but not all

Stop operation not working as expected for task management

Functional impact

Minimal repro steps

  1. Open a .NET core project with libman.json
  2. right click on libman.json, choose restore client-side libraries
  3. click the task management on the bottom, and stop the operation

Expected result

The operation should be displayed something as cancelled

Actual result

It displayed as completed

The "{0}" library could not be resolved by the "{1}" provider

The library/provider information is not populated when throwing an InvalidLibraryException. Specifically noticed this in CdnjsCataglog.GetLibraryAsync. Also, it'd be nice if the feedback mechanism made you aware of the name@version convention when the LibraryId does not contain the @ symbol at all.

InvalidLibraryException.cs should be updated to use string.Format() like so...

public InvalidLibraryException(string libraryId, string providerId)
    : base(string.Format(Text.ErrorUnableToResolveSource, libraryId, providerId))

LibMan UI command entries should be disabled if there is another operation in progress

Functional impact

We might run into conflicts if there are multiple libman tasks going on at the same time.

Minimal repro steps

  1. Trigger restore onSave
  2. Select Clean from libman.json Context Menu UI.

Expected result

We should have only one operation at a time (Restore Client-side libraries from solution context menu is considered one operation)

Add ability to grab scss files

I generally use bootstrap or foundation scss files. I keep these on a network share, so I can load them with this extension using the filesystem provider but not very well. For example:

{
      "provider": "filesystem",
      "id": "[network location]\\Bootstrap\\bootstrap-4.1.0\\scss\\",
      "path": "wwwroot/lib/bootstrap/scss/",
      "files": [
        "bootstrap-grid.scss",
        "bootstrap-reboot.scss",
        ...

First, there are 38 files in this folder, and it would be much nicer to just type *.

Second, there are two subfolders, mixins and utilities. Those each need there own entry because currently this extension won't grab items in subfolders.

What would be nice is something like this:

{
      "provider": "filesystem",
      "id": "[network location]\\Bootstrap\\bootstrap-4.1.0\\scss\\",
      "path": "wwwroot/lib/bootstrap/scss/",
      "files": [
           **/*
      ]

This would work fine for me, but others may prefer an online provider. Maybe a provider such as unpkg would work for that.

Build Status Badge

Appveyor build status badge on the readme.md is still pointing to Mads' project, not the Library Manager project.

Document "Why use this over 'xyz'?"

This project looks interesting, but I'm not seeing any documentation around the possible advantages over other package managers? Are there any particular strengths you can outline in the README or wiki?

[CLI] libman cache list should suppress metadata files

Functional impact

No functional impact, just confusing output

Minimal repro steps

  1. Execute

libman cache list --files

after installing some cdnjs libraries

Expected result

List of the library files only

Actual result

Our cache files (metadata.json) are listed along with the library files

cdnjs:
jquery
metadata.json
3.3.0\jquery.js

Further technical details

We should probably have a list of special file names/locations that we suppress

Improve error message when cleaning libraries twice

Functional impact

If there are no libraries to clean, The Clean operation still outputs "libraries were successfully deleted".
We should return "AllUpToDate" status when no deletions occurred and provide a better error message.

Library Default Destination

Instead of specifying the destination of each library, is it possible to introduce a new "default destination" setting that uses conventions at the top level of libman.json. This setting would still be able to be overwritten at each library level.

For example:

  • twitter-bootstrap version 3.3.7 library would go to wwwroot/lib/bootstrap
  • jquery version 1.12.0 library would go to wwwroot/lib/jquery/1.12.0
  • jquery version 3.3.1 library would go to wwwroot/lib/jquery/3.3.1

the libman.json would look something like this:

{
  "version": "1.0",
  "defaultProvider": "cdnjs",
  "defaultDestination": "wwwroot/lib/[LibraryName]/[Version]",
  "libraries": [
    {
      "library": "[email protected]",
      "destination": "wwwroot/lib/bootstrap"
    },
    {
      "library": "[email protected]"
    },
    {
      "library": "[email protected]"
    }
  ]
}

Thanks

Npm Support?

Hey Mads,

Is there active work to add npm support? If not I might fork and take it on if there is a loose timeline

Discussion: Optional "alias" property in library definition

Given that the same library might be defined multiple times in libman.json (i.e. for different file placements, or different library versions), we need some way to identify a specific library definition when using the command line to perform an uninstall or update command.

One solution we've devised to solve this is to introduce an optional "alias" property in the library definition to disambiguate blocks that reference the same library.

This is only of use in the command line scenario; it is redundant when editing the libman.json as the user can easily see which library block to modify.

Technical notes:
When installing a library, the provider will be asked for the real/full version of the library name.
If I ask CDNJS to install "jquery", it can return "[email protected]" as the resolved version of that short-name.
In the case where the real/full name is different to the short-name used on the command line, the short-name will be inserted as an alias in the library definition.
Then, when the use wants to update or uninstall that library definition, then can (and must) refer to the block by its alias "jquery", instead of the full name "[email protected]".
Separately, a user can force an alias by providing the --alias flag. In that case, the provided alias will be used, regardless of whether the short-name matched the real-name.

Example usage from the command line:

libman install jquery

produces the following library definition block:

  {
    "alias": "jquery",
    "library": "[email protected]"
  },

In this instance, LibMan creates the alias "jquery" because the full library name returned from the provider is different to the input library name and no other alias was specified.

To update or uninstall this block from the command line, the alias must be used.

libman update jquery
libman update jquery --to [email protected]
libman uninstall jquery

Example with --alias flag:

libman install jquery --alias latest-jquery

produces the following library definition block:

  {
    "alias": "latest-jquery",
    "library": "[email protected]"
  },

To update or uninstall this block from the command line, the alias must be used.

libman update latest-jquery

Example with no alias:

libman install [email protected]

produces the following library definition block:

  {
    "library": "[email protected]"
  },

To update or uninstall this block from the command line, the full library name must be used.

libman uninstall [email protected]

GitHub as a Provider

As the title suggests, would be nice to set GitHub as a provider at a package level. Sometimes package maintainers do not immediately publish to NPM or bower, and they have fixed bugs sitting in their GitHub repo after a PR or commit. It would be nice to point LibMan to a repository on GitHub to retrive some code.

Allow me to specify:

  • The GitHub release Tag.
  • Or the commit hash of a particular branch.
  • Or just the branch to pull the latest HEAD.

Thanks,
Brian

⏳ 🔍 "But I still haven't found what I'm for..."

Don't allow RemoveFilesAsync to continue if newManifest is null

TextViewCreationListener.OnFileSaved() has the potential to encounter an error when there is a parse error in the manifest file, but the error is swallowed and it simply returns null. This causes the call to RemoveFilesAsync() to effectively try and remove ALL files the files from the project that were added by Library Manager, which is not the desired result. Even more problematic is that it tries to do this for all files in all libraries, even if you didn't ever actually include that file in the files[] collection in the manifest. All of which return an error along the line of "Failed to delete {0}", which can take a LONG time to wait for.

NuGet package failed to install

Testing Visual Studio 2017 15.7 Preview 3 release.
Getting an error message: "NuGet package failed to install" when trying to enable the "Enable Restore on Build" option (right-click on the libman.json file and click on the "Enable Restore on Build" option).

Any ideas why?

Add IProvider method to validate libraryID

As part of the ILibraryState validation we should be calling _provider.ValdiateLibraryId for validation of provider specific library ID's. For cdnjs, we should have the format @. For FileSystem, we should validate valid file path names, etc

Wildard support?

Is there a story for using wildcards for including multiple/all files? For example, something like this...

{
  "version": "1.0",
  "defaultProvider": "cdnjs",
  "libraries": [
    {
      "library": "[email protected]",
      "files": [ "css/font-awesome.css", "fonts/*" ],
      "destination": "wwwroot/vendor/font-awesome"
    }
  ]
}

As an additional example, an icon library like open-iconic (one of the officially recommended ones for Bootstrap 4) has a ton of png images, and other assets. How would those be pulled in?

LIB004 The manifest file contains syntax errors

Functional impact

LibMan with VS 15.8.0 Preview 2.0 has stopped working for me, parsing issue with filesystem providers' "files" array.

Minimal repro steps

  1. Create New VS ASP.Net Web Application, SPA starter.
  2. Enable Client-side Library Management
  3. Add something. eg:

{
"version": "1.0",
"defaultProvider": "filesystem",
"libraries": [
{
"library": "node_modules/jquery/dist/",
"destination": "Scripts/lib/jquery",
"files": [ "jquery.min.js", "jquery.min.map" ]
}
]
}

Saving this results in:

LIB004 The manifest file contains syntax errors in the Error List pad

Expected result

This used to work last week ??

Actual result

LIB004 The manifest file contains syntax errors in the Error List pad

Further technical details

??

Restoring Client Side Packages Crashes Visual Studio

Hello, I have VS 15.7.2 and I downloaded the source code for Library Manager and created the VISX file and installed Library Manager.

When I click "Restore Client Side Packages", VS crashes. The following errors appear in Event Viewer:

Application: devenv.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.ArgumentNullException
at System.IO.Path.Combine(System.String, System.String)
at Microsoft.Web.LibraryManager.Vsix.VsHelpers.ProjectContainsManifestFile(EnvDTE.Project)
at Microsoft.Web.LibraryManager.Vsix.RestoreSolutionCommand+d__10.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.b__6_0(System.Object)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(System.Object)
at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(System.Object)
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at MS.Internal.CulturePreservingExecutionContext.Run(MS.Internal.CulturePreservingExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)

Any ideas on how to fix this?

Thanks

Delete empty folders after a clean operation

Functional impact

Currently only the immediate parent of a deleted library is also deleted if empty. We need to delete all folders (if empty) up the chain until working directory.

How to build and install this extension?

Hey, as I’m interested in this extension and since there was no current preview VSIX that I could install, I was trying to build this myself. Building the project seemed to work correctly and I also got a VSIX out of it. However, when trying to install the VSIX, I get a message that the extension cannot be installed with my currently installed products (NoApplicableSKUsException). The install log mentions the following (unfortunately localized in German):

-------------------------------------------
Microsoft VSIX Installer
-------------------------------------------
Initializing Install...
Erweiterungsdetails...
    Identifier         : Microsoft.Web.LibraryManager
    Name               : Microsoft Library Manager
    Author             : Microsoft
    Version            : 1.0.13.1887
    Description        : Install client-side libraries easily to any web project
    Locale             : en-US
    MoreInfoURL        : https://github.com/aspnet/LibraryManager
    InstalledByMSI     : False
    SupportedFrameworkVersionRange : [4.5,)

    SignatureState     : Unsigned
    Unterstützte Produkte :
        Microsoft.VisualStudio.Community
            Version : [15.6,16.0)

    Verweise           :
        -------------------------------------------------------
        Identifier   : Microsoft.VisualStudio.MPF.15.0
        Name         : Visual Studio MPF 15.0
        Version      : [15.0]
        MoreInfoURL  :
        Nested       : No

    Voraussetzungen    :
        -------------------------------------------------------
        Identifier   : Microsoft.VisualStudio.Component.CoreEditor
        Name         : Visual Studio core editor
        Version      : [15.0,16.0)

        -------------------------------------------------------
        Identifier   : Microsoft.VisualStudio.ComponentGroup.WebToolsExtensions
        Name         : ASP.NET and web development
        Version      : [15.0,16.0)

Signaturdetails...
    Extension is not signed.

Er wird nach passenden Produkten gesucht...
Installiertes Produkt gefunden - Globaler Pfad
Installiertes Produkt gefunden - Visual Studio Enterprise 2017
VSIXInstaller.NoApplicableSKUsException: Diese Erweiterung kann auf den derzeit installierten Produkten nicht installiert werden.
   bei VSIXInstaller.App.GetInstallableData(String vsixPath, Boolean isRepairSupported, IEnumerable`1& skuData)
   bei VSIXInstaller.App.Initialize(Boolean isRepairSupported)
   bei VSIXInstaller.App.Initialize()
   bei System.Threading.Tasks.Task`1.InnerInvoke()
   bei System.Threading.Tasks.Task.Execute()

As the logs note, I have VS Enterprise 2017 installed, version 15.6.4. The vsixmanifest specifies Microsoft.VisualStudio.Community as the installation target with the version range [15.6,16.0). So the installation should work fine if I understand this correctly.

Can you give me some information on what I need to do to get this up and running?

Code cleanup: namespaces do not match folder structure

Functional impact

None

Further technical details

We have many classes across multiple projects where the namespace is set to the assembly name, but ignores the directory structure within the project. For example:

Microsoft.Web.LibraryManager.Vsix
    Json
        Completion
            CompletionController.cs <- uses namespace Microsoft.Web.LibraryManager.Vsix

However:
a) This defies normal .NET convention
b) We don't do it consistently within the codebase

We should make this all consistent and follow common convention by using the AssemblyName.Folder.Path namespace pattern.

[CLI] cache list --verbosity option doesn't do anything

Functional impact

No functional impact, fit and finish bug

Minimal repro steps

  1. Issue "libman cache list --verbosity <value">

Expected result

Expected different results for different values, and errors for unsupported verbosity values

Actual result

The option seems to be ignored. Specifying "detail", "quiet", or even "foo" results in no change to the command output.

Further technical details

We should probably suppress the display of the option till it's implemented to avoid confusing users.

LibMan apparently works on invalid JSON file

Functional impact

Does the bug result in any actual functional issue, if so, what?
No, it's just surprising that it works at all. I would expect it to fail if the file is not valid JSON.

Minimal repro steps

What is the smallest, simplest set of steps to reproduce the issue. If needed, provide a project that demonstrates the issue.

  1. Paste the following into libman.json:
{
  "version": "1.0",
  "defaultProvider": "cdnjs",
  "libraries": [
    {
      "library": "[email protected]",
      "destination": "lib/jquery",
      "files": [
        "jquery.js",
      ]
    }
  ]
}

Note the comma after "jquery.js" which is not followed by another item in the array.

Expected result

LibMan would fail saying the file isn't valid.

Actual result

LibMan does what it would if the comma wasn't there.

Restore output in VS has in consistent terminology

Restore client side libraries on a non .NET Core project

libman.json

{
  "version": "1.0",
  "defaultProvider": "cdnjs",
  "libraries": [
    {
      "library": "[email protected]",
      "destination": "scripts/"
    }
  ]
}

Output:

Restore operation started...
Restoring libraries for project ConsoleApp1
Restoring library [email protected]... (WebApplication1)
scripts/mori.js written to destination (WebApplication1)
scripts/mori.min.js written to destination (WebApplication1)
Library C:/Users/prbhosal/Source/Repos/WebApplication21/ConsoleApp1/scripts/mori.js was successfuly added to project
Library C:/Users/prbhosal/Source/Repos/WebApplication21/ConsoleApp1/scripts/mori.min.js was successfuly added to project
Restore operation completed
1 libraries restored in 0.27 seconds

The below lines from output use library to mean different things:
Library:

Restoring library [email protected]... (WebApplication1)

File within a library:

Library C:/Users/prbhosal/Source/Repos/WebApplication21/ConsoleApp1/scripts/mori.js was successfuly added to project

Error copying files after a certain point, using a library with a large number of files

This is a stand alone issue for a remark I made under #42.

Specifically when using a library with a large number of files (like open-iconic, which is one of the recommended libraries for use with Bootstrap 4), it seems to encounter an error eventually where the stream is null.

Below is the libman.json file to reproduce the problem.

{
  "version": "1.0",
  "defaultProvider": "cdnjs",
  "libraries": [
    {
      "library": "[email protected]",
      "destination": "wwwroot/vendor/open-iconic"
    },
  ]
}

Access the library name property when settings the defaultDestination

It would be nice to be able to pass in the library name as a variable when setting the defaultDestination. That way the libraries could be stored in their own folders e.g.

"defaultDestination": "wwwroot/libs/{library.name}/"

Not sure on the best syntax but the above example I'd expect it to replace {library.name} with e.g. bootstrap

[CLI] "libman cache clean <provider>" command results in funky file paths in error message when file is locked

Functional impact

No functional impact, but we should clean up file paths if we can

Minimal repro steps

  1. Install some libraries, e.g. cdnjs [email protected]
  2. Go to the cache location for the library, e.g. C:\Users\alexgav.librarymanager\cdnjs\jquery\3.2.1
  3. Open one of the files, e.g. jquery.js
  4. Execute
libman cache clean cdnjs

Expected result

Error message specifying which file is locked

Actual result

Error message Failed to clean cache: The process cannot access the file '\?\C:\Users\alexgav.librarymanager\cdnjs\jquery\3.2.1' because it is being used by another process.

Further technical details

Not sure why the file path is in the "windows internals" format, \?\c:\xxx, instead of "c:\xxx", hopefully we can normalize

Discussion: Library destination root

We are considering introducing a property in the libman.json for "destinationRoot" (name to be decided).
The path specified here would be prefixed to any relative destination defined for a library.

For example:

{
  "version": "1.0",
  "defaultProvider": "cdnjs",
  "destinationRoot": "/wwwroot/lib",
  "libraries": [
    {
      "library": "[email protected]",
      "destination": "jquery"
    }
  ]
}

In the case above, the jquery library would be downloaded to "/wwwroot/lib/jquery".

If not specified, the default/implied destinationRoot would be the project root ("/").
(This is the current behavior today.)

If a library specifies a path beginning with a forward slash ("/"), destinationRoot will be ignore for that library.

Please comment. Is this a design that would work for you? Would this be your preferred approach to defining library destinations? Or are you happy to specify the full destination path for each library you're pulling down?

Does the "defaultDestination" property suit your needs better?
ie. Are you more likely to place all your library files in the same directory?
Or is the defaultDestination useless to you as you'd always want to put each library in a separate directory? (ie. to avoid potential conflicts, or for cleaner management of 3rd party libraries)

Should we combine the defaultDestination with destinationRoot into a single property that becomes both

  • the destination prefix for libraries that define a destination without a slash ("/"), and
  • the default destination for libraries that don't define a specific destination
    ?

Alternatively (and separately), should we consider using the library's name combined with defaultDestination/destinationRoot as the destination folder if no "destination" is defined for a specific library.

So, in this example, the jquery library files would go into the "/wwwroot/lib/jquery" directory.

{
  "version": "1.0",
  "defaultProvider": "cdnjs",
  "defaultDestination": "/wwwroot/lib",
  "libraries": [
    {
      "library": "[email protected]",
    }
  ]
}

Discussion: Extensibility - Who wants to extend LibMan?

Would you like to extend LibMan for your own purposes?
If so, what are your needs?

Do you want to create a new provider for serving library files?
If so:

  • Which provider/s are you looking to create?
  • What kind of properties would your provider need?

More generally, what are you looking for in an extensibility model?

.NET CLI support

It should be possible to run the various commands from the CLI

NuGet packages - message with JavaScript libraries "incompatible: use Library Manager instead"

Creating an ASP.NET Core project, and trying to add a script library from the NuGet server (NuGet PAckage Manager), this information is shown:
Incompatible: Use Library Manager instead

Previously it was shown to use Bower instead. Using Visual Studio 2017 15.7.3, and the Library Manager is not yet available, I would expect to still see the Bower message with a link to the Bower tools in Visual Studio.

Thanks,
Christian

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.