Граф коммитов

214 Коммитов

Автор SHA1 Сообщение Дата
Phil Allen 9697b44d22
Merge branch 'main' into fileMapping 2024-09-26 09:04:30 -07:00
Jimmy Lewis 407ab41035 PR feedback - XML docs on mock type 2024-08-04 02:21:26 -07:00
Jimmy Lewis 1c920cbd57 Add "3.0" manifest version to SupportedVersions
This becomes the default value for newly created libman.json files (so they will automatically get new feature support like fileMappings).
2024-08-04 02:21:26 -07:00
Jimmy Lewis 639bf3eb7d Use FileMappings when calculating the GoalState 2024-08-04 02:21:25 -07:00
Jimmy Lewis 7bcab3631e Add fileMappings to the DTOs 2024-08-04 02:21:25 -07:00
Jimmy Lewis d252a09b40 Add variable expansion in defaultDestination
This implements #68, except I used [Name] instead of [LibraryName].  It felt like LibraryName should be matched with LibraryVersion and that felt verbose, so I took the shorter versions.

This expansion is applied when we expand the ManifestOnDisk (which is either read from disk or from a raw JSON) into LibraryInstallationState.  This is where we determine to use the defaultDestination or a library-specific destination, so it should be the only place this expansion needs to occur.
2024-08-04 01:56:47 -07:00
Jimmy Lewis 20bd1d87bf
Convert to MIT license (#761)
* Change license to MIT

* Enforce and update copyright header in code files
2024-07-30 15:42:16 -07:00
Jimmy Lewis bc49e4bc2d Fix bug in FileHelpers.IsUnderRootDirectory for separator
The logic had a flaw that it didn't verify the directory separator after the directory portion.  NormalizePath strips trailing slashes, so there will never be one.  However, for IsUnderRootDirectory, there must be a separator in the path.
2024-05-26 18:43:44 -07:00
Phil Allen fb1dbe06cb
Update package references (#754)
* Update package references

Update a number of packages to be more modern
Stop shipping binaries to run in VisualStudio that VisualStudio already ships (With binding redirects/etc.)
Update the SLN file so that the Vsix project is the default startup project.

* Accept code review feedback
2024-05-24 16:44:50 -07:00
Leonid Tsarev 5c105c5805 Log errors that happen during file copy 2024-05-22 11:51:44 +03:00
Jimmy Lewis d53986ed65 make goalstate immutable 2024-05-19 01:21:20 -07:00
Jimmy Lewis b845a91b15 Change BaseProvider to use a public API for getting goal state.
Also updated Manifest to use the goal state for the uninstall scenario.
2024-05-19 01:21:20 -07:00
Jimmy Lewis 4b79145702 Use OperationGoalState for intermediate steps in Install and GenerateGoalState 2024-05-19 01:21:20 -07:00
Jimmy Lewis eb732f03b0 Introduce installation goal state
The existing LibraryInstallationState abstraction is not flexible about mapping files to their source on an individual basis.  It presumes that all files installed by a library retain the same folder hierarchy as the library they originate from.

In order to allow more flexibility, this change adds a new abstraction to wrap all installed files to their individual source files.  This eliminates the prior assumption, allowing for flexibility to install files to a different folder hierarchy than their originating library structure.

This flexibility also allows an important new concept: each destination file must be unique (to avoid collisions), but the sources are not so constrained.  A single source file may be installed to multiple destinations; by creating a mapping of destination-to-source, we can easily allow this.

This change prepares for a new feature to allow more granular mappings of files within a library.
2024-05-18 17:16:48 -07:00
Jimmy Lewis 4351103807 Rework support for @latest version
Currently, unpkg and jsdelivr support using 'latest' as a version.  When files are requested by libman, they redirect (HTTP302) to the URL for the current latest files.  We put those files into the cache like any other version (in a folder name 'latest') and all is well.

However, when a new version is released, libman continues to use the now-stale downloaded assets from the cache.  There isn't a signal to realize when to purge the latest version from the cache.

This change instead simply turns 'latest' into the latest version we determine from the provider.  There is a small risk that we are out of sync with the CDN: for example, since we get the version data from NPM, it might not match the version that e.g. jsdelivr redirects to.  But this should be extremely rare.

Doing it this way also allows cdnjs to support 'latest'.  I didn't add it to the completion items, but I did verify that it works (CLI install, restore, and the file list in VS all support foo@latest for cdnjs now too).
2024-05-12 01:39:30 -07:00
Jimmy Lewis 5ad3aee9e8 Add an error when the manifest is missing a version
Resolves #132
2024-04-30 09:36:51 -07:00
Jimmy Lewis ed687cc19d Add tests for OperationResult 2024-04-22 13:12:37 -07:00
Phil Allen 7117aa55fe
Merge pull request #725 from sprytnyserek/#682
#682 Add non-zero exit code on general exception and on error in Restore command
2024-04-22 09:11:30 -07:00
Jimmy Lewis 0885a615a6
Change Manifest.InstallLibraryAsync to return a consolidated result (#737)
This was designed to return many results, but that doesn't make a lot of sense when installing a single library.  Also, the existing code paths only lever returned an enumerable of one item, which is wasteful.
2024-04-22 08:54:44 -07:00
Phil Allen 2cce982d50
Update Library Manager build for net8 (#729)
Update Library Manager build for net8

Various fixes to update the LibraryManager repo:
Fix LibraryManager.sln so that it defaults to the vsix project
Extract TFMs that are likely to change into variables
Update to net8
SourceLink is built into net8 SDK, can drop explicit references
Update to net481, including source code references
Change version.json to major version 3.
2024-03-20 12:53:52 -07:00
Tomasz Polachowski 2547caf66c #682 Move ExitCode enum to libman project 2024-03-12 18:15:57 +01:00
Tomasz Polachowski 9fa36ea056 #682 Add non-zero exit code on general exception and on error in Restore command 2024-02-15 13:11:24 +01:00
Jimmy Lewis 2ec2978e9d
Don't write default config file during init (#720)
* Don't write default config file during init

Per #719, this can cause issues with multiple concurrent processes
executing (for example, parallel MSBuild nodes in a solution).

Retrospectively, it doesn't provide anything useful either.  It's faster
to just create the defaults in memory than to get file IO involved.
2023-10-16 23:30:43 -07:00
Jimmy Lewis 0234c50376
Update VS references (#715)
* Updated to latest (17.7 GA) packages from VS
* Addressed some warnings, old and new
  * VSTHRD analyzer complaining about unawaited tasks => explicitly discard to indicate fire-and-forget
  * OutputWindowPane.OutputString is deprecated => switch to OutputWindowTextWriter, which allows free-threaded writes to an output pane
  * Couple integration tests were failing by calling removed APIs => updated to latest (17.7) and tests now pass
  * Pinned a few package versions to resolve MSB3277 warnings
  * VS JSON parser's ArrayElementNode.Elements marked deprecated => move to ElementNodes.
2023-09-11 10:23:20 -07:00
Jimmy Lewis ee89652434 Remove duplicate PackageReference 2022-11-16 19:01:21 -08:00
Todd Grunke 55a5d85603
Switch to package refs for webtools json references (#698) 2022-09-27 17:58:56 -07:00
Jimmy Lewis ed732a882c
Adapt to Cdnjs API changes (#687)
The Cdnjs API is changing to stop including the assets for all versions of a library in the /libraries/:library API.  We were using this to determine both library versions and library files.

The changes are fairly straightforward:
- for versions, we can just use the "versions" property from the library.  It's probably easier than what we were doing before (parsing each version from an "assets" entry).
- for files, we need to invoke the /libraries/:library/:version API instead.  However, the default file (which we use for selecting the default checked box in the wizard) is on the library group, not the library-version, so we still need to get that from the first request.
- Lastly, I included fields on each API call, so that we're not downloading any data that we aren't intending to use.  This drops 10s of KB from most library group queries, since there's a lot of metadata we don't care about.  We can always add more back later.
2022-06-21 10:44:48 -07:00
Jimmy Lewis 0832ac74a1
Update unit tests to target net6.0 (#675)
As netcore2.1 is out of support, these tests fail to run on the CI
agents.  Updating to net6.0 will allow the tests to continue running.

Updating the src projects to net6.0 would also mean that they would stop
functioning for customers who did not have net6.0 installed.  This can
be a concern for both the MSBuild package and the CLI.  Such a change
should only be made when we are bumping the major version.
2022-03-25 16:05:02 -07:00
Jimmy Lewis a8f81f6a59
Improve error message in wizard when installing an invalid library name (#651)
Addresses #508
2022-01-03 14:42:09 -08:00
Jimmy Lewis afb45647a2
Add a flag to silently init using the default provider (#659)
Addresses #368.
2022-01-03 13:42:32 -08:00
Jimmy Lewis 8e040ba18d
Support prerelease versions from Unpkg (#658)
The API call used by the Unpkg catalog only returns the latest release
version.  In order to get prerelease versions as well (e.g. for the
Upgrade lightbulb), we need to specifically get all versions.

Addresses #349.
2022-01-03 12:58:38 -08:00
Jimmy Lewis cde0d959a1
Ensure completions in Add wizard are sorted (#647)
There isn't a guarantee that the data from providers is sorted in the
desired order (e.g. for versions, sorted descending).  This change
ensures we sort the completion items before showing them in the search
box flyout.

In the JSON completion scenario (which is similar), each completion item
is instead represented by a CompletionEntry implementation which
implements IComparable<T> for that completion type.  The editor
completion stack handles the sorting for us already.

Addresses #531.
2022-01-03 00:15:25 -08:00
Jimmy Lewis c450309e95
Wizard should respect defaultProvider if specified (#652)
Addresses #397
2021-12-16 17:31:59 -08:00
Jimmy Lewis 607a9e90c9 Update dependencies to the latest, convert NuGet to CPVM
This change converts to using the Central Package Version Management
feature in NuGet, enforcing that all PackageReference versions are
tracked in one central place.

I also bumped up the dependencies for most of the packages that we rely
upon.

Code changes are to address new analyzer issues from updating to the
latest analyzer packages.
2021-07-01 11:32:52 -07:00
Rob Johnston 422d40002e
fix: provide error message for unknown provider. (#608)
* fix: provide error message for unknown provider.

If a provider is given and it is not one of the available providers, output an invalid operation message like "Provider 'foo' is not installed.

Closes #134
2020-09-23 13:13:20 -07:00
Jimmy Lewis 2c3ffc6918 Implement JsDelivr handling of prerelease and GitHub versions 2020-09-19 22:42:30 -07:00
Jimmy Lewis 062000733a Find latest Cdnjs version after sorting
Cdnjs library metadata used to be returned in order from newest to oldest, but that is no longer the case - now it seems to be alphabetical by version.  In many cases, this leads to recommending the oldest version of the library.
2020-09-19 22:42:30 -07:00
Rob Johnston 53b18ecba8 refactor: rename "CacheService" directory.
There is a "CacheService.cs" file within the "CacheService" directory, so the directory was renamed and a namespace added to match the folder structure.
2020-09-17 18:23:21 -04:00
Jimmy Lewis 7ecebc214f PR feedback and cleanup
- Add ConfigureAwait(false) to the files changed in this PR
- Remove unnecessary using in UnpkgCatalogTest
- Remove unused sample string CdnjsProviderTest
2020-09-14 23:41:06 -07:00
Jimmy Lewis fadf309d47 Refactor common caching semantics into ICacheService
This change reduces the repentitiveness of implementing request-and-cache or check-cache-else-request patterns when requesting provider metadata.  This simplified code in each provider, and also centralized testing that behavior on the CacheService class rather than duplicating cache behavior testing.

It also removes the GetCatalogAsync and GetMetadataAsync as those names were Cdnjs-specifc, and the catalog is just another form of metadata.

Testing was also largely refactored to apply fakes at the ICacheService layer instead of the underlying IWebRequestHandler, as that should be transparent to the Catalog implementations.  There are a couple exceptions to verify that no web requests are issued at all during some test scenarios.
2020-09-14 23:41:05 -07:00
Jimmy Lewis f9ce4dd344 Implement metadata caching for JSDelivr provider 2020-09-14 23:41:05 -07:00
Jimmy Lewis 08db45a3ec Implement metadata caching for Unpkg provider 2020-09-14 23:41:05 -07:00
Jimmy Lewis c0294b25be Used stale cached Cdnjs metadata if request fails
Currently we download these files and cache them locally with a hardcoded lifetime.  Once the file is expired, we attempt to download a new copy; however, if that request fails, we just fail the operation.  With this change, we'll at least fall back to the already-stored copy, which may be stale but should still work in most cases.
2020-09-12 16:36:40 -07:00
Jimmy Lewis bc0ceea40b Use non-deprecated NuGet properties 2020-05-17 22:03:58 -07:00
Jimmy Lewis 09763e6224 Remove test references to WebRequestHandler.Instance
Using mocked out responses instead makes the tests faster and more resilient to network or service provider irregularities.

There are still some tests that invoke code paths using real web requests, those can be addressed in another change.
2020-05-12 13:04:17 -07:00
Jimmy Lewis e9eaf7fea9 Remove "FullEndToEnd" so-called unit tests 2020-05-12 13:04:17 -07:00
Jimmy Lewis 5e7e65109e Refactor JsDelivr and Unpkg catalog tests to use fake data 2020-05-12 13:04:17 -07:00
Jimmy Lewis 3c91d11ab1 Inject IWebRequestHandler to NPM search utilities 2020-05-12 13:04:17 -07:00
Jimmy Lewis 3183a41917
Make tests less prone to breaking when jQuery releases. (#584)
Ideally these wouldn't make any live web requests, but we don't have that level of DI built into the CLI commands yet (or their tests) yet.  Using specific versions will still test the scenarios, but we won't have tests break whenever a new jQuery release is published.
2020-05-12 13:03:14 -07:00
Jimmy Lewis 6392a54e91
Include the cache location in 'libman cache list' (#583) 2020-05-12 13:02:37 -07:00