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

@rushstack/rush-serve-plugin

v5.124.2

Published

A Rush plugin that hooks into a rush action and serves output folders from all projects in the repository.

Downloads

931

Readme

@rushstack/rush-serve-plugin

A Rush plugin that hooks into action execution and runs an express server to serve project outputs. Meant for use with watch-mode commands.

Supports HTTP/2, compression, CORS, and the new Access-Control-Allow-Private-Network header.

# The user invokes this command
$ rush start

What happens:

  • Rush scans for riggable rush-serve.json config files in all projects
  • Rush uses the configuration in the aforementioned files to configure an Express server to serve project outputs as static (but not cached) content
  • When a change happens to a source file, Rush's normal watch-mode machinery will rebuild all affected project phases, resulting in new files on disk
  • The next time one of these files is requested, Rush will serve the new version. Optionally, may support signals for automatic refresh.

Live Build Status via Web Socket

This plugin also provides a web socket server that notifies clients of the build status in real time. To use the server, configure the buildStatusWebSocketPath option in common/config/rush-plugins/rush-serve-plugin.json. Specifying / will make the web socket server available at wss://localhost:<port>/.

The recommended way to connect to the web socket is to serve a static HTML page from the serve plugin using the globalRouting configuration.

To use the socket:

import type {
  IWebSocketEventMessage,
  IOperationInfo,
  IRushSessionInfo,
  ReadableOperationStatus
} from '@rushstack/rush-serve-plugin/api';

const socket: WebSocket = new WebSocket(`wss://${self.location.host}${buildStatusWebSocketPath}`);

const operationsByName: Map<string, IOperationInfo> = new Map();
let buildStatus: ReadableOperationStatus = 'Ready';

function updateOperations(operations): void {
  for (const operation of operations) {
    operationsByName.set(operation.name, operation);
  }

  for (const [operationName, operation] of operationsByName) {
    // Do something with the operation
  }
}

function updateSessionInfo(sessionInfo: IRushSessionInfo): void {
  const { actionName, repositoryIdentifier } = sessionInfo;
}

function updateBuildStatus(newStatus: ReadableOperationStatus): void {
  buildStatus = newStatus;
  // Render
}

socket.addEventListener('message', (ev) => {
  const message: IWebSocketEventMessage = JSON.parse(ev.data);

  switch (message.event) {
    case 'before-execute': {
      const { operations } = message;
      updateOperations(operations);
      updateBuildStatus('Executing');
      break;
    }

    case 'status-change': {
      const { operations } = message;
      updateOperations(operations);
      break;
    }

    case 'after-execute': {
      const { status } = message;
      updateBuildStatus(status);
      break;
    }

    case 'sync': {
      operationsByName.clear();
      const { operations, status, sessionInfo } = message;
      updateOperations(operations);
      updateSessionInfo(sessionInfo);
      updateBuildStatus(status);
      break;
    }
  }
});