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

shell-bash.js

v1.0.8

Published

Create Your Own Terminal With Custom Commands!

Downloads

3

Readme

▶ Bash.js

Create Your Own Terminal/Shell With bash.js

🔨 CREATORS

@FilipinoAko

@Cassy

⚠ WARNING

This is a beta version... so it has some bugs that we dont know

📁 DEPENDENCIES

• discord.js- I Use Discord.JS For The Collection

• readline- To make the custom shell

• EventEmitter- To Create Events

❔ DOCUMENTATION

• Creating Client:

const { Client } = require('shell-bash.js')

const terminal = new Client()

Using new Client() you can create a new client but... it will show errors...

Thats Because We Dont Define The Options

const { Client } = require('shell-bash.js')

const terminal = new Client({
	id: "docs",
	prefix: ">>>"
})

The id option will be the name of your terminal

The prefix option is your terminal prefix

Heres all the options:

• prefix- <string>: The prefix for the terminal

• id- <string>: The name of the terminal

• messages- <json> Terminal Messages

Heres how you can make custom messages for your terminal

const { Client } = require('shell-bash.js')

const terminal = new Client({
	id: "docs",
	prefix: ">>>",
	messages: {
    commandNotFound: "Terminal: [COMMAND] Not Found",
		bashErr: "Terminal: [ERROR]"
  }
})

With messages options you can add custom messages

Messages Options:

• commandNotFound- <string>: When Command Is Not Found! (You can add [COMMAND] to see what command is runned)

• bashErr- <string>: When system receives error (You can add [ERROR] to see what error is received)

Creating Commands:

const { Client } = require('shell-bash.js')

const terminal = new Client({
	id: "docs",
	prefix: ">>>",
	messages: {
    commandNotFound: "Terminal: [COMMAND] Not Found",
		bashErr: "Terminal: [ERROR]"
  }
})

terminal.registerCommand()

Heres how you can make commands! but just like creating client without options you will receive errors...

So Lets Add The Options!

const { Client } = require('shell-bash.js')

const terminal = new Client({
	id: "docs",
	prefix: ">>>",
	messages: {
    commandNotFound: "Terminal: [COMMAND] Not Found",
		bashErr: "Terminal: [ERROR]"
  }
})

terminal.registerCommand({
	name: "name",
	description: "description", // default value: description
	category: "category", // default value: BashJS
  aliases: ["aliases1", "aliases2"], // Default Array: []
	run: async(client, args) => {
		// args is an array of the arguments
		console.log(args[0]) // if you know how array works... your good

		// client is an json of you client data
		console.log(client)
	} // the code that will run if you execute the command you create, (params: client, args)
})

For Creating Command Easily You Can Also Use The Creator We Made

const { Client, Command } = require('shell-bash.js')

const terminal = new Client({
	id: "docs",
	prefix: ">>>",
	messages: {
    commandNotFound: "Terminal: [COMMAND] Not Found",
		bashErr: "Terminal: [ERROR]"
  }
})

// Create The Command
const cmd = new Command()

// Set things
cmd.setName('name')
cmd.setDescription('description') // default value: No Description
cmd.setCategory('category') // default value: BashJS
cmd.setAliases(["aliases1", "aliases2"]) // default array: BashJS
cmd.execute(async(client, args) => {
	// args is an array of the arguments
	console.log(args[0]) // if you know how array works... your good

	// client is an json of you client data
	console.log(client)
}) // the code that will run if you execute the command you create, (params: client, args)

terminal.registerCommand(cmd.toInfo()) // convert the data to json

Params:

• args- arguments or string you type after the command (e.g: name bruh<- This is the argument number 1)

• client- Your client data but on JSON

Starting Terminal:

Now We Setup All!! We can now start our terminal

const { Client } = require('shell-bash.js')

const terminal = new Client({
	id: "docs",
	prefix: ">>>",
	messages: {
    commandNotFound: "Terminal: [COMMAND] Not Found",
		bashErr: "Terminal: [ERROR]"
  }
})

terminal.registerCommand({
	name: "name",
	description: "description",
	category: "category", 
  aliases: ["aliases1", "aliases2"],
	run: async(client, args) => {
		console.log(args[0])
		console.log(client)
	}
})

terminal.start()

Using terminal.start() you can run your terminal

And If You use terminal.destroy() you can stop your terminal

Your done you have your own terminal!! 😃

🔧 EVENTS

• command - params(client, args)

• ready - params(client)

• stop - params(client)

• error - params(error)

const { Client } = require('shell-bash.js')

const terminal = new Client({
	id: "docs",
	prefix: ">>>",
	messages: {
    commandNotFound: "Terminal: [COMMAND] Not Found",
		bashErr: "Terminal: [ERROR]"
  }
})

terminal.registerCommand({
	name: "name",
	description: "description",
	category: "category", 
  aliases: ["aliases1", "aliases2"],
	run: async(client, args) => {
		console.log(args[0])
		console.log(client)
	}
})

terminal.on('command', async(client, args) => {
	console.log(args)
})

terminal.on('ready', async(client) => {
	console.log('Terminal Running...')
})

terminal.on('stop', async(client) => {
	console.log('Stopped')
})

terminal.on('error', async(error) => {
	console.log(error)
	terminal.destroy()
})

// Use All Events In the top of terminal.start() or it will not work
terminal.start()

Example Project: https://replit.com/@FilipinoAko/bashJSExample/

🔗 LINKS

• Youtube Channel: Filipino Ako

• Twitch Channel: FilipinoAkoLive

• Discord Server: FilipinoAko Discord

😀 THANK YOU

Enjoy Using Our Package