MIT License

项目介绍

msh-contrib/xeon 是一个托管在 GitHub 上的开源项目,主要使用 JavaScript 编写,采用 MIT License 许可证,目前获得 404 个 Star、10 次 Fork。

仓库全名
msh-contrib/xeon
开源许可证
MIT License
Star 数
404
Fork 数
10
未关闭 Issue
7

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 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…

完整内容见 GitHub 原始 README 或本页 。

常见问题

xeon 用什么语言开发?

主要使用 JavaScript 编写,采用 MIT License 许可证,目前有 404 个 Star。

xeon 可以免费商用吗?

仓库采用 MIT License 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 xeon 的源码?

可以直接克隆仓库:git clone https://github.com/msh-contrib/xeon.git,默认分支为 master;安装与运行步骤见仓库 README。

xeon 最近还在维护吗?

仓库最近一次更新为 2017年5月26日,当前有 7 个未关闭 Issue;Star 数为 404,可作为社区活跃度的参考。

关于

module loader for bash scripts with `require` style

描述取自 GitHub 官方 API,中文内容由 GitRead 中文社区 编辑团队整理。

简要分析

热度分
429
价值分
245
活跃状态
活跃

语言占比

JavaScript

README

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

评论

暂无评论