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

@jincoco/backstage-plugin-webterminal

v0.1.1

Published

A Backstage plugin that integrates a web-based terminal into your Backstage application, enabling real-time terminal access through WebSockets.

Downloads

1

Readme

Backstage Plugin WebTerminal

This plugin seamlessly integrates a WebTerminal into your Backstage application, offering a convenient way for users to interact with a terminal interface within your app. Powered by xterm.js and WebSocket technology, it delivers a robust and responsive terminal experience.

Setup

1. Add the plugin to your frontend app

Start by installing the plugin package in your Backstage frontend app:

cd packages/app && yarn add @jincoco/backstage-plugin-webterminal

2. Configure the plugin in app-config.yaml

Next, configure the plugin in your app-config.yaml file to specify the WebSocket server URL:

# app-config.yaml, you can use wss:// or ws://
webterminal:
  baseUrl: wss://your.websocket.server

Ensure you replace wss://your.websocket.server with the actual WebSocket server URL.

3. Import and use the components

  • TerminalPage: This component represents the WebTerminal page.

Here's an example of how to integrate these components into your Backstage app:

// Example in your routes configuration file
// App.tsx
import { WebTerminalPage } from '@jincoco/backstage-plugin-webterminal';

// Adding WebTerminalPage to your routes
<Route path="/web-terminal" element={<WebTerminalPage />} />

4. Ensure that your websocket server setting

Ensure your WebSocket server is correctly configured. Below is an example of setting up a simple terminal server using node-pty and WebSocket. This example uses Node.js to create the WebSocket server and manage the terminal sessions:

// server.js
// A example of a simple terminal server using node-pty and WebSocket
const express = require('express');
const WebSocket = require('ws');
const pty = require('node-pty');

const app = express();
const port = 3838;

// Serve static files from the React app
app.use(express.static('build'));

// Start the server
const server = app.listen(port, () => {
  console.log(`Server listening on port ${port}`);
});

// Create WebSocket server
const wss = new WebSocket.Server({ server });

wss.on('connection', (ws) => {
  // Create a new pty process
  const shell = process.env.SHELL || 'bash';
  const ptyProcess = pty.spawn(shell, [], {
    name: 'xterm-color',
    cols: 80,
    rows: 30,
    cwd: process.env.HOME,
    env: process.env,
  });

  // Handle data from the pty process
  ptyProcess.onData((data) => {
    ws.send(data);
  });

  // Handle data from the WebSocket
  ws.on('message', (msg) => {
    ptyProcess.write(msg);
  });

  // Cleanup when the connection is closed
  ws.on('close', () => {
    ptyProcess.kill();
  });
});

NGINX configuration for proxying with SSL

If you're using NGINX to proxy with SSL, ensure your configuration includes the necessary settings:

server {
    listen 443 ssl;

    ssl_certificate /etc/nginx/ssl/certificate.crt;
    ssl_certificate_key /etc/nginx/ssl/certificate.key;

    server_name my.server.url;

    location / {
        proxy_pass http://my.websocket.ip:3838;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
    }
}
  • proxy_set_header Upgrade $http_upgrade: This ensures that the WebSocket connection is upgraded from HTTP to WebSocket protocol.

  • proxy_set_header Connection 'upgrade': This keeps the connection open and instructs NGINX to maintain the connection upgrade.

Make sure to replace with your actual server name and update SSL certificate paths accordingly.

Features

Interactive Terminal: Users can interact with a terminal interface directly within your Backstage app.

WebSocket Integration: Utilizes WebSocket for real-time communication between the frontend and backend.WebSocket

Customizable Configuration: Easily configure the WebSocket server URL to suit your environment.

Screenshots

alt text

Contributing

We welcome contributions to improve this plugin. If you have any suggestions, bug reports, or feature requests, please open an issue or submit a pull request.