npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vscode-extension-updater-gitlab

v3.0.8

Published

Visual Studio Code custom extension updater for private extension marketplaces

Downloads

63

Readme

Visual Studio Code custom extension updater for private extension marketplaces

CI npm

For context and motivation, please look at the Private extension market a.k.a side loading.

This package does not provide the extension marketplace (with the ability to pick an extension and install it), but assuming you point your VS Code user population to download and install the extension manually, as long as your extension starts this updater at its activation, this takes care of the usual workflow:

  1. Checks whether new version is available
  2. Asks user, whether they want to download and install now
  3. Downloads the new version .vsix to a local temp file
  4. Installs the new version
  5. Offers to re-load the window to load the new version

This package purpose is to:

  • Provide a base class for extension update abstracting from the type of the private repository
  • Provider specific implementations (please contribute, if you see fit). So far there is support for
    • Confluence wiki
    • Gitlab package registry

Here is a demo of confluence extension:

Extension auto-update from Confluence wiki attachment

Get Started

Fetch the package using

npm install vscode-extension-updater-gitlab

Using the Gitlab Package registry based private extension repository

Put this to your extension.ts (or .js if you insist) activate function:

import { GitLabExtensionUpdater } from 'vscode-extension-updater-gitlab';

export function activate(context: ExtensionContext): void {

    // ... your extension activation code...

    setTimeout(() => {
        checkNewVersion(context, false);
    }, 30000); // give it 30sec before checking
}

async function checkNewVersion(context: ExtensionContext, showUpToDateConfirmation: boolean): Promise<void> {
    try {
        await new GitLabExtensionUpdater(context, {
            gitlabHost: 'linux-git.myorg.com',
            projectId: 31775,
            packageName: 'dev',
            packageType: 'generic',
            showUpToDateConfirmation: showUpToDateConfirmation
        }).getNewVersionAndInstall();
    }
    catch (err) {
        showErrorMessage('Failed to check for new version of the the extension: ', err);
    }
}
  • gitlabHost is your gitlab URL.
  • projectId is your package registry project's ID. Settings > General > Project ID
  • packageName is the fuzzy name of the package where artifact is uploaded.
  • packageType is the exact name of package type. Currently 'generic'.

Adding manual check for new version

VS Code supports extension-specific commands. They show in the menu that displays when you click on the cogwheel button of your extension in the Extensions view. Add this to your package.json:

{
    "contributes": {
        "commands": [
            {
                "command": "yourExt.checkForExtensionUpdate",
                "title": "yourExt: Check for new extension version..."
            },
        ],
        "menus": {
            "extension/context": [
                {
                    "command": "yourExt.checkForExtensionUpdate",
                    "when": "extension == publisherId.extensionId && extensionStatus == installed"
                }
            ]
}

... where publisherId, extensionId and yourExt must be replaced with the corresponding values from your package.json.

Add this to your extension.ts activate() method:

    context.subscriptions.push(commands.registerCommand("yourExt.checkForExtensionUpdate", () =>
        checkNewVersion(context, true).catch(showError)));

In this case, we pass true to the showUpToDateConfirmation argument, which will show notification even if there is no new version.

Implementing your own adapter to other custom back-end

Look at the ConfluenceExtensionUpdater class as an example of implementation. Essentially, the only thing you may need to do is to implement this abstract method:


import { ExtensionUpdater, ExtensionVersion } from './ExtensionUpdater';

export class YourExtensionUpdater extends ExtensionUpdater {

    constructor(context: ExtensionContext, options: YourMarketplaceOptions) {
        super(context);
        this.url = options.url;
        // ...
    }

    protected async getVersion(): Promise<ExtensionVersion> {
        // download
    }
}

And the base class would do the same if you integrate it into your extension's activate function.

Original repo with Confluence downloader examples

jan-dolejsi/vscode-extension-updater