Giter VIP home page Giter VIP logo

xeon's Introduction

3D Fonts

xeon

Join the chat at https://gitter.im/hzlmn/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 understand that u want to load file from node modules and will generate proper bundle file.

Here is sample module that use could play with and use as reference

hzlmn/xeon-package-example

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.