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

xeon

v0.0.3

Published

module loader for bash scripts

Downloads

2

Readme

xeon

module loader for bash scripts with node require("module") style

about

xeon tiny node.js based tool

that simplify the process of creation modular and reusable bash scripts,

large or small, for personal usage or sysadmin tasks

install

install node first then with npm do

npm i -g xeon

note it may require sudo mode to install global node package

check availability with xeon --help

if you see help message you are ready to go

example

Lets simply create one module that we'd like to use in future

For example here is one that have function in it that print your name to console

Pretty simple

hello.sh

log_hello() {
  local name=$1
  echo "Hello, $name"
}

and lets add one more module that say bye to u

bye.sh

log_bye() {
  local name=$1
  echo "Bye, $name"
}

some fancy module as well

unicorn_power.sh

unicorn() {
  echo "meow"
}

and also some module that use other modules as well

module_that_use_others.sh

require("./bye.sh")
require("./unicorn_power.sh")

# and use functions from your modules
unicorn # will echo meow
log_bye "Oleh" # will echo Bye, Oleh

then create entry, for example, app.sh and require some modules too

app.sh

 require("./bye.sh")
 require("./module_that_use_others.sh")

 log_bye "Oleh"

then type at cmd xeon --input ./app.sh --output ./build/build.sh

it will read your requires, build dependency graph, resolve it and generate ./build/build.sh file,

that you can run with bash cmd

there is an file watching option as well, just add --watch flag to previous command

Okay moving next...

Imagine that we create some useful badass script, and want to share it with someone or just save for future usage.

In typical workflow u just create snippet or put it somewhere on remote machine .eg and then seaching it for hours or days, when u really need it.

With xeon you can use your shell script as npm modules as u used to (if you have node.js background).

So i have script that i upload to npm with own dependencies as well

in your app folder just install an npm module

  $ npm i --save my_module_name

Then use it in our entry app.sh

app.sh

 require("my_module_name")
 require("./bye.sh")
 require("./module_that_use_others.sh")

 log_bye "Oleh"

Xeon undertand that u want to load file from node modules and will generate proper bundle file.

Next imagine you find some great script on internet, that do what u actually need and want to use it with your script

just add require("http://some.external.domain/awesome_script.sh");

app.sh

 require("http://some.external.domain/awesome_script.sh")
 require("my_module_name")
 require("./bye.sh")
 require("./module_that_use_others.sh")

 log_bye "Oleh"

Thats all, xeon will download and include that file as well

Note! for security reasons downloading external files not allowed by default

You should use flag --external with previous command. Just be sure that u load good stuffs.

plans for future

Right now, xeon just analyze your dependencies and merge files in correct order.

It's a pretty straightforward way of doing bundling.

However, I am currently working on AST generator/stringifier for bash scripts,

that will allow xeon to build things faster, analyze code you are going to bundle and also transform scripts in a way

you want it to be (.eg fish shell scripts could be transformed to bash scripts while build process)

license

MIT