joelspadin-garmin / vscode-private-extension-manager

Private extension manager for Visual Studio Code
103 stars 22 forks source link

Initial attempt at supporting channels #4

Closed montaguek-garmin closed 4 years ago

montaguek-garmin commented 4 years ago

Allows channels to be specified for each extension in a repository based on the package ID. Expects that pre-release versions are pushed with a --tag='channelName' to set the dist-tag appropriately. If not specified, the 'latest' channel is used by default.

Could also update the extension info view to indicate which channels are available for tracking and couple this to a command that allows switching between channels w/o manually editing settings.

See #2

montaguek-garmin commented 4 years ago

I've refactored to only support specifying channels via user settings, so now it's global for all registries. I believe that this has implicitly addressed the bulk of the comments above, but feel free to suggest improvements as needed.

One thing I'm not happy with (but wasn't sure what would be a better way) is in Registry.ts::getPackages, I'm calling getPackageMetadata to determine if the requested channel is valid. I don't think that the npm library is doing any caching, so this approach results in two npm requests for every update check. Suggestions would be appreciated here.

// Ensure requested channel is valid, otherwise fallback to latest
if (channel !== 'latest') {
    let meta: any = await this.getPackageMetadata(result.name);
    if (!(channel in meta['dist-tags']) && !(channel in meta['versions'])) {
        channel = 'latest';
    }
}

I tried moving the logic into the getPackageMetadata routine itself, but then I didn't know which tag was actually used if it defaulted to 'latest'. This was causing the HTML to display the requested tag, but the actual version was 'latest'.

joelspadin-garmin commented 4 years ago

Looks good to me. Also, yay, the CI checks I added work!