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

@microsoft/vscode-azext-azureutils

v3.0.1

Published

Common Azure utils for developing Azure extensions for VS Code

Downloads

6,445

Readme

VSCode Azure SDK for Node.js - Azure Utils (Preview)

Build Status

This package provides common Azure utilities for Azure VS Code extensions, and is intented to be used alongside @microsoft/vscode-azext-utils.

Usage

You must call registerAzureUtilsExtensionVariables first in your extension's activate() method. The first parameter of the function passed in will always be an IActionContext, which allows you to specify custom telemetry and describes the behavior of this command. The simplest example is to register a command (in this case, refreshing a node):

registerAzureUtilsExtensionVariables(...);
registerCommand('yourExtension.Refresh', (context: IActionContext, node: AzExtTreeItem) => {
    context.telemetry.properties.customProp = "example prop";
    context.telemetry.measurements.customMeas = 49;
    node.refresh();
});

Azure Extension Tree Data Provider

ExampleTree

Display Azure Resources

Follow these steps to create your basic Azure Tree:

  1. Create an AzExtTreeItem (or AzExtParentTreeItem) describing the items to be displayed under your subscription:

    export class WebAppTreeItem extends AzExtTreeItem {
      public static contextValue: string = "azureWebApp";
      public readonly contextValue: string = WebAppTreeItem.contextValue;
      private readonly _site: Site;
      constructor(parent: AzExtParentTreeItem, site: Site) {
        super(parent);
        this._site = site;
      }
    
      public get id(): string {
        return this._site.id;
      }
    
      public get label(): string {
        return this._site.name;
      }
    }
  2. Create a SubscriptionTreeItemBase that provides the tree items you just implemented. It must implement at least hasMoreChildrenImpl and loadMoreChildrenImpl:

    NOTE: Methods suffixed with Impl should not be called directly - just implemented.

    export class SubscriptionTreeItem extends SubscriptionTreeItemBase {
        private _nextLink: string | undefined;
    
        public hasMoreChildrenImpl(): boolean {
            return this._nextLink !== undefined;
        }
    
        public async loadMoreChildrenImpl(clearCache: boolean, _context: IActionContext): Promise<WebAppTreeItem[]> {
            if (clearCache) {
                this._nextLink = undefined;
            }
    
            const client: WebSiteManagementClient = createAzureClient(this.root, WebSiteManagementClient);
            const webAppCollection: WebAppCollection = this._nextLink === undefined ?
                await client.webApps.list() :
                await client.webApps.listNext(this._nextLink);
            this._nextLink = webAppCollection.nextLink;
            return webAppCollection.map((site: Site) => new WebAppTreeItem(this, site)));
        }
    }
  3. Create an AzureAccountTreeItemBase that provides the subscriptions you just implemented. It must implement at least createSubscriptionTreeItem:

    export class AzureAccountTreeItem extends AzureAccountTreeItemBase {
      public createSubscriptionTreeItem(root: ISubscriptionContext): SubscriptionTreeItemBase {
        return new SubscriptionTreeItem(this, root);
      }
    }
  4. Finally, set up the tree in your extension's activate() method. Instantiate an AzureAccountTreeItem and add it to context.subscriptions since it's a disposable. Then instantiate an AzExtTreeDataProvider, passing in your root tree item and the loadMoreCommandId (which maps the 'Load More...' node to the command registered by your extension).

    const azureAccountTreeItem = new AzureAccountTreeItem();
    context.subscriptions.push(azureAccountTreeItem);
    const treeDataProvider = new AzExtTreeDataProvider(azureAccountTreeItem, "appService.loadMore");
    context.subscriptions.push(vscode.window.createTreeView("azureAppService", { treeDataProvider }));

License

MIT