feat: add getPackageAvailableVersions to public API and bump API to 1.1.0 - #1682
feat: add getPackageAvailableVersions to public API and bump API to 1.1.0#1682Eduardo Villalpando Mello (edvilme) wants to merge 3 commits into
Conversation
4f563d7 to
540d41d
Compare
Add PythonPackageGetterApi.getPackageAvailableVersions so API consumers can query a package's available versions (newest-first), delegating to the environment's package manager and resolving to undefined when unsupported. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3f16397e-0917-4efb-8d75-566c71ebf9ba
|
Adding "skip tests" label since this functionality already exists but is now being exposed to the public API |
| ### Changed | ||
|
|
||
| - Added the optional `options?: GetPackagesOptions` parameter to `PackageManager.getPackages(environment, options?)` and `PythonPackageGetterApi.getPackages(environment, options?)`. Consumers can set `options.skipCache` to request fresh package data. | ||
| - Changed `PackageManager.refresh(environment)` from `Promise<void>` to `Promise<Package[] | undefined>`, allowing implementations to return the refreshed package list. |
There was a problem hiding this comment.
this is a big change here- we would need to go to 2.0 if we want to change the return value of this method. Any other ways we could maybe do that?
There was a problem hiding this comment.
I can look into having it return nothing for now, and then maybe discuss later on when reviewing the API
| The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), | ||
| and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
|
||
| ## [1.1.0] |
There was a problem hiding this comment.
The published 1.0 package has top-level main and types; api/package.json now has only conditional exports. This accumulated unpublished change is not mentioned in the changelog.
There was a problem hiding this comment.
preserve top-level main and types alongside exports, and test packed ESM and legacy CommonJS consumers.
There was a problem hiding this comment.
The api file and types are generated inline by the pipelines (#1619). I can update the changelog to mention that as well
| - Added the optional `options?: GetPackagesOptions` parameter to `PackageManager.getPackages(environment, options?)` and `PythonPackageGetterApi.getPackages(environment, options?)`. Consumers can set `options.skipCache` to request fresh package data. | ||
| - Changed `PackageManager.refresh(environment)` from `Promise<void>` to `Promise<Package[] | undefined>`, allowing implementations to return the refreshed package list. | ||
| - Changed `PythonPackageGetterApi.refreshPackages(environment)` from `Promise<void>` to `Promise<Package[] | undefined>`, exposing the refreshed package list to API consumers. | ||
|
|
There was a problem hiding this comment.
would also want to packed-package contract tests before publishing
Eleanor Boyd (eleanorjboyd)
left a comment
There was a problem hiding this comment.
see two items about refresh and the exported top level items
|
🔒 Automated review in progress — Stella Huang (@StellaHuang95) is auto-reviewing this PR. |
| "name": "@vscode/python-environments", | ||
| "description": "An API facade for the Python Environments extension in VS Code", | ||
| "version": "1.0.0", | ||
| "version": "1.1.0", |
There was a problem hiding this comment.
Warning · Non-blocking recommendation
Please confirm the published npm version history before releasing 1.1.0. The changelog contains a 1.37.0 entry, so publishing 1.1.0 would be a downgrade if 1.37.0 was ever published; reconcile the changelog or select a version above the published latest.
|
|
||
| - Added the optional `options?: GetPackagesOptions` parameter to `PackageManager.getPackages(environment, options?)` and `PythonPackageGetterApi.getPackages(environment, options?)`. Consumers can set `options.skipCache` to request fresh package data. | ||
| - Changed `PackageManager.refresh(environment)` from `Promise<void>` to `Promise<Package[] | undefined>`, allowing implementations to return the refreshed package list. | ||
| - Changed `PythonPackageGetterApi.refreshPackages(environment)` from `Promise<void>` to `Promise<Package[] | undefined>`, exposing the refreshed package list to API consumers. |
There was a problem hiding this comment.
Warning · Non-blocking recommendation
Changing PackageManager.refresh from Promise<void> to Promise<Package[] | undefined> breaks external PackageManager implementations that return Promise<void>. Please confirm that external implementations are unsupported or document why this implementer-facing breaking change is appropriate for a minor release.
| @@ -319,6 +320,17 @@ export class PythonEnvironmentApiImpl implements PythonEnvironmentApi { | |||
| } | |||
There was a problem hiding this comment.
Warning · Non-blocking recommendation
Please add coverage for both manager behaviors: returning available versions when supported and resolving undefined when the underlying manager omits the optional hook. The latter relies on the internal wrapper's guard and is the documented fallback contract for this new public method.
Stella Huang (StellaHuang95)
left a comment
There was a problem hiding this comment.
Approved via Review Center.
Summary
PythonPackageGetterApi.getPackageAvailableVersionsto the public API so consumers can query a package's available versions@vscode/python-environmentsfrom1.0.0to1.1.0API changes
PythonPackageGetterApi.getPackageAvailableVersions(environment, packageName): Promise<Pep440Version[] | undefined>— exposes a package's available versions (newest-first) to API consumers, delegating to the environment's package manager and resolving toundefinedwhen version listing is unsupportedPep440Versionfor package manager version APIsPackageInfo.isTransitiveandGetPackagesOptions.skipCacheGetPackagesOptionsparameter toPackageManager.getPackagesandPythonPackageGetterApi.getPackagesPackageManager.refreshandPythonPackageGetterApi.refreshPackagesto return the refreshed package list when availableValidation
npm run lintnpm run compile-testsnpm run unittest(1494passing,5pending)git diff --check