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

termly.js

v2.5.6

Published

Simple, Extensible, Hackable and Lightweight Javascript Browser Terminal Simulator!

Downloads

22

Readme

Termly.js

Simple, Extensible, Hackable and Lightweight Browser Terminal Simulator!

Want to showcase your new shiny CLI Tool you just released? Want to write HowTos on how some commands behaves? Want to create a simulated sandbox of linux-like commands to help people learn? You want to have fun (as I had) making your personal website readable from a fake terminal? Doit interactively!

Documentation

Installing

Get the zip Package directly or better:

npm install termly.js
# OR
yarn add termly.js
# OR
bower install termly.js

Getting Started

You can choose to use one of the two bundle coming with Termly.js, the main package have the shell only and all it's utilities you can use it as you wish, the prompt bundle is a simple DOM Wrapper that handles inputs and outputs and DOM manipulation, for the sake of simplicity with this you only have to attach a container and Style your terminal

<!-- Get the Shell only package -->
<script src="node_modules/termly.js/dist/termly.min.js"></script>

<!-- OR Get the Shell + a Prompt I/O wrapper -->
<script src="node_modules/termly.js/dist/termly-prompt.min.js"></script>

Or get directly from the sources (Babel+Bundler workflow)

// With a bundler
// @NB ES6 Classes are exported
const Shell = require('termly.js') // Shell only
// OR
const Prompt = require('termly.js/bin/classes/Prompt') // Init with a Prompt IO Wrapper

Read the docs to know the differences

Basic Usage

Both the Shell and the Prompt wrapper can get parameters at instantiation whose most important are a custom Filesystem and a set of custom commands, both fall back to defaults if not provided.

Using the Prompt Wrapper

You can attach Termly.js to a DOM container and have it do the work of creating and setting up input/output field and handlers and only care of styling it:

<script src='dist/termly-prompt.min.js'></script>
<script>
  // Documentation for options in the next section
  var shell = new TermlyPrompt('#container', { /* options object */ })
</script>

Read the docs at website for all the options

Using the Shell Class

A more advanced approach to build something custom that suites your needs would be to use Termly.js Shell Class, thus extending it with a wrapper and handle yourself all the DOM Input/Output in the way you desire it to behave.

<script src='dist/termly.min.js'></script>
<script>
  // Documentation for options in the next section
  var shell = new Termly({ /* options object */ })
  shell.run('help')
  //> 'Commands available: help, whoami, about, arguments, cd, ls, cat, man, http'
</script>

Read the docs at website for all the options

Changelog

2.5.6 - stable

  • Prompt.js: Array output returned from commands execution now stringified

2.5.5

  • Fixed Filesystem methods cd-ing into files bug which cames with the change in how filesystem got inited some patch ago.

2.5.4

  • Fixed ENV object not getting the defaults if empty object

2.5.3

  • fixed printnev to print obejcts

2.5.2

  • added pwd command

2.5.1

  • Filesystem root dir structure instantialized as an instance of File()

2.5.0

  • Added Commands printenv and export
  • Added env object in shell class
    • You can provide an env: {} with all the variables you want set in shell.env at instantiation
    • You can see current session variables calling printenv
    • You can set a variable during runtime with export VAR=value or export var='long value'
  • fake user and hostname are taken from the provided env (or from default), no more in the options object

Contributing

Actually this fits my needs and it works as expected, but as someone pointed to my this can be useful so if you have nice ideas and you want to contribute get your copy and fiddle with!

If you have to open a PR if possible squash your commits before sending, so I can give it a look more easily.

If there are any issue let me know, I'll give it a look when I can.

Authors

Acknowledgments

minimist Got inspiration to write my command parser

Promise Polyfill

Fetch API Polyfill

Some CSS I got here and there for the demo because I get bored styling, I really don't remember from who sorry :( Thank you anyway

License

This project is licensed under the GNU GPL v3 License - see the LICENSE.md file for details